LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sorting arrays and keeping them in sync

I have 3 1d arrays (# of elements can change but all 3 arrays always have
the same number of elements) and i want to sort on one of the arrays while
keeping the other two in sync (ie If array 1 element 3 is moved to element 1
then element 3 elements in arrays 2 and 3 must also be moved to their
respective element 1.

I thought I could do this by using the index and cluster array which then
gives the proper sort as viewed in an indicator, but i cant seem to then
extract the 3 arrays properly. Instead of getting 3 arrays with 'x' elements
I get 'x' arrays with 3 elements.

Any suggestions?
0 Kudos
Message 1 of 3
(2,702 Views)

Check out this example.

It lets you choose an array to sort on, uses that to buid an array of clusters which contain the array element and an index.

This array is then sorted using the sort 1-d array.

The sorted array is then used to re-arrange all of the input arrays in-place and returns the results.

It should do the trick I would think.

Ben


Ben Rayner
Certified LabVIEW Developer
www.DSAutomation.com

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 3
(2,702 Views)
problem solved

"Burklund" wrote in message
news:6wH4c.5222$po.137317@attbi_s52...
> I have 3 1d arrays (# of elements can change but all 3 arrays always have
> the same number of elements) and i want to sort on one of the arrays while
> keeping the other two in sync (ie If array 1 element 3 is moved to element
1
> then element 3 elements in arrays 2 and 3 must also be moved to their
> respective element 1.
>
> I thought I could do this by using the index and cluster array which then
> gives the proper sort as viewed in an indicator, but i cant seem to then
> extract the 3 arrays properly. Instead of getting 3 arrays with 'x'
elements
> I get 'x' arrays with 3 elements.
>
> Any suggestions?
>
>
0 Kudos
Message 3 of 3
(2,702 Views)