Re: Sorting a multidimensional array by multiple keys
- From: Peter Otten <__peter__@xxxxxx>
- Date: Sat, 31 Mar 2007 18:39:48 +0200
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))
Peter
.
- Follow-Ups:
- Re: Sorting a multidimensional array by multiple keys
- From: Duncan Booth
- Re: Sorting a multidimensional array by multiple keys
- References:
- Sorting a multidimensional array by multiple keys
- From: Rehceb Rotkiv
- Re: Sorting a multidimensional array by multiple keys
- From: bearophileHUGS
- Re: Sorting a multidimensional array by multiple keys
- From: Rehceb Rotkiv
- Re: Sorting a multidimensional array by multiple keys
- From: Rehceb Rotkiv
- Re: Sorting a multidimensional array by multiple keys
- From: Duncan Booth
- Sorting a multidimensional array by multiple keys
- Prev by Date: Re: os.system questions
- Next by Date: Re: Long way around UnicodeDecodeError, or 'ascii' codec can't decode byte
- Previous by thread: Re: Sorting a multidimensional array by multiple keys
- Next by thread: Re: Sorting a multidimensional array by multiple keys
- Index(es):