0

Possible Duplicate:
Sorting a tuple that contains tuples

hi
I have a list that goes A=[[a,'3'],[g,'1'],[y,2]]
I am looking for a quick way to arrange it according to the numbers (second dimension), so
NewA=[[g,'1'],[y,'2'],[a,'3']]
thanks
ariel

Community
  • 1
  • 1
ariel
  • 91
  • 1
  • 3
  • 4
  • 1
    The input/output is inconsistant, it is likely supposed to be the string '2' and not the int 2. – kevpie Dec 14 '10 at 17:36

1 Answers1

2
from operator import itemgetter
newA = sorted(a, key=itemgetter(1))
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005