this customize sort did not work ,what's wrong?

thinke365 thinke365 at gmail.com
Sat Jan 23 15:57:15 EST 2010


l = list()
l1 = list((1, 2, 3, 4))
l2 = list((1,2))
l3 = list((1, 2, 3, 4, 5))
l.append(l1)
l.append(l2)
l.append(l3)
print l

def sort_by_list(E1, E2):
    print len(E1), len(E2)
    return len(list(E1)) > len(list(E2))

l.sort(cmp=sort_by_list)
print l

output:
[[1, 2, 3, 4], [1, 2], [1, 2, 3, 4, 5]]
2 4
5 2
[[1, 2, 3, 4], [1, 2], [1, 2, 3, 4, 5]]

the order of the elements in the list did not change!
-- 
View this message in context: http://old.nabble.com/this-customize-sort-did-not-work-%2Cwhat%27s-wrong--tp27289860p27289860.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list