[SciPy-user] Finding Element Position and Sorting

Lorenzo Isella lorenzo.isella@gmail....
Sat Jan 12 09:43:32 CST 2008


Dear All,
Unfortunately I have not been able to find online what I was looking for.
Say that you have N_ob objects labeled 0,1,...,N_ob-1 objects which 
belong to N_g  groups  labeled in turn with 0,1,...,N_g<=N_ob. You know 
how many objects each group is made up of.
To keep it simple, consider 8 objects and 3 groups, and assume you know 
what group each object belongs to.
For instance, the object vector is given by:
Obj=   [0 1 2 3 4 5 6 7]
The vector giving the membership of each object to any of the groups 0,1 
or 2 is:
Mem=[1 1 0 2 2 0 2 1].
So, 2 objects  in group 0, 3 in group 1 and 3 in group 2.
Now, I am looking for an efficient way of building a vector getting 
together the identities of the objects in the 1st, 2nd and 3rd group, i.e.:
Id=[2 5 | 0 1 7 | 3 4 6]
         0        1        2

Any suggestions?
Many thanks

Lorenzo


More information about the SciPy-user mailing list