1

I have these two lists and I combine them by zip then I want to sort them but it gives me this result (Ard,Ger,Sla,ard) while I wanted to be (ard,Ard,Ger,Sla). any idea?

N = ["ard","Ard","Ger","Sla"]
L = ["7","4","2","3"]
x=zip(N,L)
x.sort()
for i in x:
    print i[0]
jesy2013
  • 319
  • 2
  • 12

1 Answers1

6

Pass a key argument to sort:

x.sort(key=lambda (a, b): (a.lower(), b))

The output is:

Ard
ard
Ger
Sla
Blender
  • 289,723
  • 53
  • 439
  • 496