LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

searching lists

I have a list of sequential numbers.  Given a new number, I want to find where in the list it goes. Are there existing vi's that will do this for me?
Thanks.
 
0 Kudos
Message 1 of 7
(3,130 Views)
So you want to sort the list? there is a vi for that under the array menu.
- there is always an easy way, but it is always the hardest to find
0 Kudos
Message 2 of 7
(3,122 Views)
If you are search for an array of INTEGER values and only one, you can use the function that it's in the array palette "search 1d array".
 
if it's double it give's a little more of work.
 
If you need, send me another post
Software developer
www.mcm-electronics.com





PORTUGAL
0 Kudos
Message 3 of 7
(3,121 Views)

Lacking detials I'll respond as I read you Q.

Just add the new element to your array and then pass that array to the "Sort 1-d array" if it needs to be asending or add a "reverse 1-d array" after if you wan it to be decending.

If you have two (or more collumns) and you want to sort based on one one of the collumns, convert the 2-d array to a 1-d array of cluster (where the first element in the cluster is the sort collumn) adn wire that to the "sort 1-d array". Then convert it back.

I hope my "shot-gun" approach has something you can use!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 7
(3,116 Views)
I can used the search 1-d array for a number that is greater than the new number and/or less than the new number. I was hoping for something already written.
0 Kudos
Message 5 of 7
(3,115 Views)
Easy. Elegant. You win the prize. Thanks.
0 Kudos
Message 6 of 7
(3,109 Views)
If the list is already sorted use Threshold 1D-Array primitive



This will return the (fractional) position of the new values (threshold y) in the original array. You can even start searching from a specific number.
For your purpose you might want to use a RoundTowardInfity primitive.


Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 7 of 7
(3,086 Views)