Sorting a multidimensional array by multiple keys
Duncan Booth
duncan.booth at invalid.invalid
Sat Mar 31 15:57:10 EDT 2007
More information about the Python-list mailing list
Sat Mar 31 15:57:10 EDT 2007
- Previous message (by thread): Sorting a multidimensional array by multiple keys
- Next message (by thread): Extending embedded python of multiple interpreters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Peter Otten <__peter__ at web.de> wrote: > Duncan Booth wrote: > >>>>> from operator import itemgetter >>>>> data.sort(key=itemgetter(0)) >>>>> data.sort(key=itemgetter(1)) >>>>> data.sort(key=itemgetter(4)) >>>>> data.sort(key=itemgetter(3)) > > Or, in Python 2.5: > >>>> data.sort(key=itemgetter(3, 4, 1, 0)) > Thanks, I'd forgotten itemgetter had that strangley assymmetric behaviour of returning either a single value or a tuple.
- Previous message (by thread): Sorting a multidimensional array by multiple keys
- Next message (by thread): Extending embedded python of multiple interpreters
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list