LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sorting out 1D array of strings

Solved!
Go to solution

@FireFist-Redhawk wrote:

OpenG's "Remove Duplicates...


Some users (such as me!) don't have any OpenG tools installed. 😄

0 Kudos
Message 11 of 16
(938 Views)

cha@bellflight.com wrote:

Thanks for mentioning wiebe@CARYA's LabVIEW 2020 approach, altenbach,

 

I have many LabVIEW 2018 SP1 NI PXIe hardware applications. I don't think I want LabVIEW 2020 upgrade.


The maps and sets are a very, very good reason to upgrade.

 

But I know there can be powers to stop upgrades...

0 Kudos
Message 12 of 16
(925 Views)

@altenbach wrote:

See if this can give you some ideas.

 

altenbach_0-1610235376342.png

 


Seems to me this is the best solution. And a good one, too.

 

Only addition would be that you can put it in a malleable VI, so it works for any data type.

 

And of course the routine fails if the first element is an empty element 😋. For strings this might never happen, but for integers you'll run into this quickly. A solution that is performant isn't that easy. If you put things in the loop (like a compare), it will get slower. You'd need to make sure the shift register is initialized with something that is not the first element, or strip the first element and always add it to the result. But that needs extra care if the array is empty.

Message 13 of 16
(921 Views)

wiebe@CARYA wrote:
And of course the routine fails if the first element is an empty element 😋

Yes, an important concern. I actually thought it was a feature here to drop leading empty elements. 😄

 

For integers, you could initialize with the "first element-1". For floating point you can initialize with NaN, but be aware that it the array has adjacent NaNs, they will not get eliminated. (A NOT-EQUAL comparison with NaN is always TRUE!), so if you also want to eliminate adjacent NaNs while keeping only one. More code is needed.

0 Kudos
Message 14 of 16
(904 Views)

I know I am going to be shot for this, but I call them like I see them.  I am stunned NI didn't see the wisdom in including a string sort tool in LabVIEW's design.

 

 

In fact, I still think I am wrong about this it is such a no-brainer.

0 Kudos
Message 15 of 16
(508 Views)

@3d0g wrote:

I know I am going to be shot for this, but I call them like I see them.  I am stunned NI didn't see the wisdom in including a string sort tool in LabVIEW's design.

 

In fact, I still think I am wrong about this it is such a no-brainer.


There are so many ways users might want to sort strings, they probably decided not to burn their hands on it. I'd probably have done the same.

 

The sort vim (EDIT: vi.lib\Array\Sort 1D Array.vim) allows users to define compare (equal? and greater?) (in several ways). It's a bit technical, though.

0 Kudos
Message 16 of 16
(488 Views)