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

2011-04-03 Thread Lie Ryan
On 04/04/11 00:14, ranjan das wrote: > > 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

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

2011-04-03 Thread ranjan das
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