c2=[] row1=[1,22,53] row2=[14,25,46] row3=[7,8,9] c2.append(row2) c2.append(row1) c2.append(row3)
c2 is now:
c2
[[14, 25, 46], [1, 22, 53], [7, 8, 9]]
how do i sort c2 in such a way that for example:
for row in c2: sort on row[2]
the result would be:
[[7,8,9],[14,25,46],[1,22,53]]
Well, your desired example seems to indicate that you want to sort by the last index in the list, which could be done with this:
sorted_c2 = sorted(c2, lambda l1, l2: l1[-1] - l2[-1])