LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sort Array

Solved!
Go to solution

Dear All,

I want to sort my array based on another array. Basically, I have an array of unsorted strings in no sequential order. I want to sort the array to my sorted array in sequence order. For example, my array is called to, the race go bob. I want to make it look like GO to the race bob. Does anyone have any solutions on how to tackle this problem. 

0 Kudos
Message 1 of 6
(5,633 Views)

I don't understand your task.

 

If you already have a sorted array, why aren't you just using that one?

0 Kudos
Message 2 of 6
(5,625 Views)

If I understand your question correctly... then this is one of the tasks in LabVIEW that isn't the most elegant.

 

The simplest way I know to accomplish this is to just make an array of clusters and then sort that array... it will sort by the first element in the cluster.

 

I've attached an example.

0 Kudos
Message 3 of 6
(5,611 Views)

@BowenM wrote:

If I understand your question correctly... then this is one of the tasks in LabVIEW that isn't the most elegant.

 

The simplest way I know to accomplish this is to just make an array of clusters and then sort that array.  If you have an array of clusters and sort that array it will sort by the first item in that cluster.

 

I've attached an example.


Don't forget that if there is a tie, it goes to the next element in the cluster, and so on.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 6
(5,604 Views)

In LabVIEW 2018 Sort 2DArray was added in the array palette. Can sort by column or row and a specific index. No more making clusters needed..

Snap5.png

 

 

 

 

mcduff

0 Kudos
Message 5 of 6
(5,589 Views)
Solution
Accepted by topic author Rayzab

this appears to be a toy problem, however....

your desired output contains an ascending and a descending sequence (in terms of length or alphabetical order)

3 2 2 3 4

 

bob-sort2.png

 

 

 

 

 

 

Message 6 of 6
(5,543 Views)