On Mon, Jul 23, 2012 at 4:02 PM, Ali Torkamani wrote:
> By the way, I myself, have this solution:
>
>> How can we get the indices of values in the original list after sorting a
>> list?
>>
>
> (Pdb) A=[ 1, -1, 0, 7, 9, 1.3, 2.9 ]
> (Pdb) sorted(zip(A, range(len(A))), key = lambda x: x[0])
> [(-1,
On Mon, Jul 23, 2012 at 5:40 PM, Alan Gauld wrote:
>
> create a sorted copy
>
> L1 = [...original data...]
> L2 = sorted(L1)
>
> Now you can compare indexes except if there are duplicate elements
> and you need to know which specific copy is where. In that case
> I think you need to use id() but e
On 23/07/12 20:55, Ali Torkamani wrote:
Hi every one,
How can we get the indices of values in the original list after sorting
a list?
create a sorted copy
L1 = [...original data...]
L2 = sorted(L1)
Now you can compare indexes except if there are duplicate elements
and you need to know which s
I found the solution, we should use numpy's argsort(...):
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 ha
On 24 July 2012 01:25, Ali Torkamani 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 or
By the way, I myself, have this solution:
How can we get the indices of values in the original list after sorting a
> list?
>
>
(Pdb) A=[ 1, -1, 0, 7, 9, 1.3, 2.9 ]
(Pdb) sorted(zip(A, range(len(A))), key = lambda x: x[0])
[(-1, 1), (0, 2), (1, 0), (1.3, 5), (2.9, 6), (7, 3), (9, 4)]
But compare
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]
If yo