LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sorting array, how to get the new index of the last value ?

Solved!
Go to solution

Hi all !

 

I'm using a SubVI which adds a cluter of parameters to an array, and then sort this array depending on one of the parameter in the clusters.

This works fine, thanks to the examples I found in this forum 🙂

 

but now I'd like to know if there's any way to get at the end the new index of the cluster firstly added.

 

see VI attached

 

Thanks

0 Kudos
Message 1 of 4
(2,606 Views)
Solution
Accepted by topic author _zeyol_

You are taking the size of the array and inserting the new element at that index this is nothing but build array and a simple build would do this.

 

In your question I guess you are asking about the index of the element that you inserted after sorting the array, right? In this case you can compare the cluster element you are inserting at the initial with the array of cluster that you get after sorting the array. So this will give you the index of the element that you are inserting initially.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 4
(2,601 Views)

Hi

 

You will get the indices of the elements, in the order of sorting from the second For Loop..use these indices to identify the index of the last element that was added.

 

attached is an image of how it should work

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 3 of 4
(2,593 Views)

"You are taking the size of the array and inserting the new element at that index this is nothing but build array and a simple build would do this."

 

thanks for the tip ^^ I've been using LabVIEW for a few mounths now but I'm still not familiar with some basic things...


 

 

"In your question I guess you are asking about the index of the element that you inserted after sorting the array, right? In this case you can compare the cluster element you are inserting at the initial with the array of cluster that you get after sorting the array. So this will give you the index of the element that you are inserting initially." 
I did it and it works fine, see attached image

 

"You will get the indices of the elements, in the order of sorting from the second For Loop..use these indices to identify the index of the last element that was added."

 

it works also very well !

  


 

thanks for both answers, my main VI now works as expected 😛

 

 

0 Kudos
Message 4 of 4
(2,582 Views)