07-19-2018 01:44 PM
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.
Solved! Go to Solution.
07-19-2018 02:06 PM
I don't understand your task.
If you already have a sorted array, why aren't you just using that one?
07-19-2018 02:28 PM - edited 07-19-2018 02:37 PM
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.
07-19-2018 02:36 PM
@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.
07-19-2018 03:04 PM
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..
mcduff
07-20-2018 05:10 PM
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