Schwartzian transform for tuple in list

David Di Biase dave.dibiase at
Wed Sep 24 23:02:33 CEST 2008


I have a rather large list structure with tuples contained in them (it's
part of a specification I received) looks like so:

The list can range from about 800-1500 tuples in size and I'm currently
sorting it with this:

a_list.sort(lambda a, b: cmp(b[3], a[3]))

I'm actually sorting it by the last value in the tuple (d2). I have been
researching more efficient sorting algorithms and came across Schwartzian
transform via these links:


I get what's happening (  but I'm not sure if it is more
efficient in my scenario, if it is then I have no idea how to implement it
properly :-/

Would be great if a true expert would offer a suggestion for me...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list