LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sort data

Solved!
Go to solution

Hello,

 

I am attempting to make the case structure dynamic (or if there is another method), whereby if the entries in the first column change, that I can get the correct array output.  In the attached VI, the case structure is hardcoded with the first column data.

 

In essence, I am trying to sort the array based on the entries in the first column.   Is there a dynamic solution for this?

 

Thanks,

hiNi.

Download All
0 Kudos
Message 1 of 8
(3,081 Views)
Turn each row of the 2d array into a cluster, resulting in a 1d array of clusters. Sort this array using the 1d sort node, then turn result back into a 2d array. Use loop parallelization when converting to/from cluster.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 8
(3,077 Views)

@mikeporter wrote:
Turn each row of the 2d array into a cluster, resulting in a 1d array of clusters. Sort this array using the 1d sort node, then turn result back into a 2d array. Use loop parallelization when converting to/from cluster.

Mike...

Something like this...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 8
(3,066 Views)
Yes, and if all the OP will ever need is sort by the first column it could get even simpler. Auto index the 2d array to get rows, use the array to cluster to convert it into a cluster. The 1d sort node, sorts the array by items in the cluster. Item 0 is the first sort term, item 1 the second and so on.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 8
(3,048 Views)

Hello Mike,

 

I am trying to implent your last solution but I am not getting the right output.  The "Array" does not match the "Current Array",i.e. Item 0 should be 136, item 1 should be 174 and so on...The "Array" is not the same as "Current Array"sort array.PNG

 

Thanks,

hiNi.

Download All
0 Kudos
Message 5 of 8
(3,028 Views)

You're trying to hard. This is what I meant:

 

Another sort.png

 

Like the note says, the conversion to the cluster defaults to 9 elements. So you may need to reset that. The conversion from cluster to array, doesn't care how may items are in the cluster.

 

Mike...

 

PS: If yiou want the first row to be handled differently, strip it off before you do this...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 8
(3,019 Views)

Hello Mike,

 

If I change the index on the "Current Array", you can see that the array is indexed correctly...Index 0 starts with 136, index 1 starts with 174 and so on...with your solutions, "Array" does not change till I index the array to 39, i.e. index 39 = start 174.

 

I am trying to get the data in a format such that I can select the relevant index and get the corresponding number...i.e. index 0 = 136, index 1 = 174 and so on.  I would like to use this array (just like "Current Array") for data manulipation later on.  Your solution is not allowing me to index the array correctly.

 

Thanks,

hiNi.

0 Kudos
Message 7 of 8
(3,011 Views)
Solution
Accepted by topic author hiNI

Maybe with a little help from Variant Attributes...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 8
(2,980 Views)