in need of some sorting help

ianaré ianare at gmail.com
Fri Mar 3 05:27:08 CET 2006


arrrg i did it again, not enough explanation... new to asking for
programing help online.
anyway the reason is that the list can be rearanged later in the
program by another function, and i need a way to put it in order
again.. so yes it is doing some pretty funky stuff, lol.
so although your method works well, it would have been problematic for
me to implement a two list system in the app for various reasons. but
you did make me understand  a way to sort this thing finally: sort by
base path then by full path, which is how i came up with:

files.sort(key=lambda x: x.lower())
files.sort(key=lambda x: os.path.dirname(x))

well actually i am sorting first by full name, then by base, taking
advantage of python2.4's stable sort().

If you can think of a more efficient (faster) way of doing this please
let me know. i'm not crazy about having to sort this list twice, it can
get pretty big (50,000 entries)

anyway thanks all, this thing had me stuck for over a month !!




More information about the Python-list mailing list