sorting list and then return the index of the sorted item
Antoon Pardon
apardon at forel.vub.ac.be
Tue May 3 09:49:15 EDT 2005
More information about the Python-list mailing list
Tue May 3 09:49:15 EDT 2005
- Previous message (by thread): [Errno 9] Bad File Descriptor on Windows 2003 Server & Py 2.4.1
- Next message (by thread): sorting list and then return the index of the sorted item
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Op 2005-05-03, custard_pie schreef <ckwiguno at gmail.com>: > I need help sorting a list...I just can't figure out how to sort a list > and then return a list with the index of the sorted items in the list > for example if the list I want to sort is [2,3,1,4,5] > I need [2,0,1,3,4] to be returned > Can someone help please.... > Something like this: >>> lst = [2,3,1,4,5] >>> inx = range(len(lst)) >>> inx.sort(lambda x,y: lst[x] - lst[y]) >>> print inx [2, 0, 1, 3, 4] -- Antoon Pardon
- Previous message (by thread): [Errno 9] Bad File Descriptor on Windows 2003 Server & Py 2.4.1
- Next message (by thread): sorting list and then return the index of the sorted item
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list