[Tutor] Original indices after Sorting

Sarma Tangirala tvssarma.omega9 at gmail.com
Mon Jul 23 22:05:59 CEST 2012


On 24 July 2012 01:25, Ali Torkamani <torkamani at gmail.com> wrote:

> Hi every one,
> How can we get the indices of values in the original list after sorting a
> list?
>
> for example:
>
> (Pdb) A=[ 1, -1, 0, 7, 9, 1.3, 2.9 ]
> (Pdb) A.sort()
> (Pdb) A
> [-1, 0, 1, 1.3, 2.9, 7, 9]
> (Pdb)
>
>
> Now I want to have the original indices of the sorted list, i.e:
>
> [1, 2, 0, 5, 6, 3, 4]
>
>
>
This should be of help ...
http://stackoverflow.com/questions/7851077/how-to-return-index-of-a-sorted-list...
 it uses the sorted method to sort a list rather than A.sort()


-- 
An monkey typed up this email. Please excuse him if he made a stupid error!
  .
    .
. . .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120724/b29ade6d/attachment.html>


More information about the Tutor mailing list