LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to sort my second array according to the first array sorting order ?

Solved!
Go to solution

I have 2 array,

1st array contains number 1 to 9 in a random order ,

2nd array contains random number,

I want to : sort array1 , then sort array2 according to array 1 sorting order , for example:

 

array1 : 1,2,3,4,5,6,8,9,7

array2 : 464,353,345,456,567,678,88,99,77

after sorting (element 9 become 7, 8 become 9, 7 become 8):

array1 : 1,2,3,4,5,6,7,8,9

array2 : 464,353,345,456,567,678,77,88,99

0 Kudos
Message 1 of 7
(1,828 Views)
Solution
Accepted by topic author PULSE.Wannabe

Yes, that's easily possible. What have you tried?

 

altenbach_0-1668360525909.png

 

0 Kudos
Message 2 of 7
(1,818 Views)
Solution
Accepted by topic author PULSE.Wannabe

as.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 7
(1,815 Views)

ah I never use index and bundle cluster array, I didn't concatenate them because I thought it will also sort the 2nd array.

 

thanks !

0 Kudos
Message 4 of 7
(1,719 Views)

Arrays of cluster will sort by cluster order. The values of the second element are only relevant where there are duplicates in the first value.

0 Kudos
Message 5 of 7
(1,714 Views)

got it , thanks so much !

0 Kudos
Message 6 of 7
(1,676 Views)

I made a set of Array manipulation code posted over on VIPM.IO which supports many additional function as VIMs so that the data types can transform as needed.  One of the functions I named the Foreign Key Sort, which sorts one array based on another.  Under the hood it basically does what others have suggested here, but it does return other optional things such as the pointers (indexes) of how the rearrange went.

0 Kudos
Message 7 of 7
(1,624 Views)