From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

return indices of sorted array

I'd like to sort an array and be able to use the sorted indices to sort another array (easy in Matlab).

I see there's an OpenG vi, but I was wondering if it can be done in standard LabVIEW.

Thanks!

0 Kudos
Message 1 of 4
(2,272 Views)

Never mind ... I ended out writing my own vi to sort returning index and then sort using index (attached).

Download All
0 Kudos
Message 2 of 4
(2,266 Views)

I know this topic is pretty old, but I stumbled here searching for a way to do the same thing as you. After trying out your VI, I just had an idea for a much simpler solution:

Bundle the indices with the values and sort an array of clusters. The sort function will sort according to the first item of the cluster, and your indices will stay associated with each value.

0 Kudos
Message 3 of 4
(2,195 Views)

Sorting the array of clusters is what's done in the OpenG VI mentioned in the original post. I'm not sure why the posted didn't just use that VI as it's freely available and its source code is open.


___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,172 Views)