thinke365 <thinke...@gmail.com> wrote: > jesus, now i fixed it, using odd lambda sort. > l.sort(lambda x,y: cmp(len(x), len(y))) > print l > > BUT I AM STILL CONFUSED WHY COSTOMIZED SORT FAILED TO SORT AS IT IS > PROGRAMMER!
Try reading the documentation: >>> help(list.sort) Help on method_descriptor: sort(...) L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 Your comparison function returned True or False, not -1, 0, +1 -- http://mail.python.org/mailman/listinfo/python-list