I am seeking help on a large sorting problem. I have a vector, call it VECTOR1, which is of a large size: e.g. (100,000x1). Every element is a different real number. My problem is I want to be able to easily return the elements which contain, say, the highest (or lowest) X values (X<100,000). That is - I do not want the values themselves, but the number of the element (the location) they occur at in VECTOR1 is what is of interest. For example, if element 28,282 of VECTOR1 contains the lowest value in the whole of the VECTOR, I want element 1 of the new vector (in the example below - VECTOR3) to contain the real number 28,282.
The way I am currently going about this (where I want the lowest elements of VECTOR1) is something like:
Code: Select all
vector VECTOR2 = @sort(VECTOR1) 'Sort the original vector of values
vector(X) VECTOR3 'define our output vector
for !k = 1 to X
for !p = 1 to 100,000
if VECTOR1(!p) = VECTOR2(!k) then
VECTOR3(!k) = !p
!p = 100,000 'end the loop early as the condition has been satisfied
endif
next
next
Best wishes, and again - eternally grateful for your help,
Charlie
