From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
Freelion8

Sort 1D array should output sorted index numbers

Status: Declined

Declined for reasons listed in AristosQueue's reply

When you use Sort 1D array function, it sorts items but does not output sorted index numbers. This is a problem especially if a particular 1D subarray is used to sort an 2D array and if subarray has identical items in it. It makes it hard to rebuild the 2D array based on the sorted 1D subarray. If sorted index numbers are provided, 2D array can easily be rebuilt.

Senior Software Developer
4 Comments
AristosQueue (NI)
NI Employee (retired)

Providing that would kill performance of the Sort 1D Array node. Tracking all the swapped indexes is major overhead for a sort operation that isn't needed most of the time, and when you do need it, there are often better ways to achieve it.

 

If you want to sort a 2D array, use the vi "vi.lib\Array\Sort 2D Array.vim". Internal to that VI, you'll find code that manipulates the sorted array of indexes if you want the index list for some other purpose.

Darren
Proven Zealot
Status changed to: Declined

Declined for reasons listed in AristosQueue's reply

Freelion8
Member

Aristo

Sort 2D array.vim has its own flaws already. Instead of declining the idea, you can let developer select the index array output by implementing "Activate" input node (T or F) and make F default so that it would not bother the performance if the feature is not activated. I think this feature is almost needed and make a good improvement going forward.

Senior Software Developer
RavensFan
Knight of NI

Can't you just sort a 1-D array of clusters where the cluster consists of the string value and the original index position?  Sure it would take some looping to create the cluster to sort, or break the sorted cluster back into 2 arrays.

 

RavensFan_0-1582865422713.png