[Tutor] sorting based on elements which are nested in a list

ranjan das ranjand2005 at gmail.com
Sun Apr 3 16:14:01 CEST 2011


I have a list which I want to sort based on ('a','b','c') first and then
based on (1,2,3)

How do i do these using itemgetter() since the list is nested


A=[('k3', ['b', 3]), ('k2', ['a', 1]), ('k1', ['a', 3]), ('k4', ['c', 2])]


The solution I am looking for is

A_sorted=[ ('k2', ['a', 1]), ('k1', ['a', 3]), ('k3', ['b', 3]) ('k4', ['c',
2])]

Please suggest

Regards,
ranjan



--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110403/b80a9d71/attachment.html>


More information about the Tutor mailing list