On Fri, Jun 25, 2010 at 1:18 AM, Vikram <kp...@rediffmail.com> wrote:
> Suppose i have this: > >>> z1 = > [[34,44,'1011'],[40,60,'1011'],[50,50,'1013'],[40,20,'1011'],[10,30,'1013']] > how do i sort the nested list z1 so as to obtain: > bla = > [[34,44,'1011'],[40,20,'1011'],[40,60,'1011'],[10,30,'1013'],[50,50,'1013']] > It appears that you want to sort by the 3rd, then 1st and then 2nd element of each sublist. This is how you could do it: z1.sort(key=lambda x: (x[2],x[0],x[1])) print z1 OR sorted(z1,key=lambda x: (x[2],x[0],x[1])) _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers