Efficient comparison of array location in two lists [message #75219] |
Mon, 21 February 2011 15:59 |
Matt Francis
Messages: 94 Registered: May 2010
|
Member |
|
|
I have two sets of data, both comprised of a STRARR labelling the data
and a FLTARR of the data itself.
I want to compare the data in the two sets, but the order and number
of labels are different, so I'd first need to to find which array
elements in each FLTARR correspond to the same label.
It's trivial to see how this can be accomplished by simply looping
over either data set and using WHERE(STRCMP()), but is there a way to
do this without the loop?
To make it clear, say I had:
foo1 = ['a','b','c']
foo2 = ['a','c','b']
I want a single line that produces:
IDL_MAGIC(foo1,foo2,indx1,indx2)
print,indx1,indx2
-> [0,1,2] [0,2,1]
So that could compare
foo1_data[indx1] and foo2_data[indx2] in whatever way I wanted.
Any thoughts?
|
|
|