LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting serial port data

Hi, I'm trying to sort data that is coming through serial port in the format below.  I simply need to sort these 8 rows of data first by the first number (which indicates the sensor that is tripping) and then by the number after the ":".  That is a time in ms number.  

 

3: 0.0000
1: 5.8567

2: 6.4567
4: 8.3567
1: 10.050
3: 12.5678
4: 18.456

2: 22.050

 

So essentiall need to reproduce it to look like this:

1: 5.8567

1: 10.050

2: 6.4567

2: 22.050

3: 0.0000

3: 12.5678

4: 8.3567

4: 18.456

 

I tried using some sort 1D array and labview says its not found.  The sort 2D array is fine, but the 1D does not work.  

Rudy_01_0-1765988765403.png

 

0 Kudos
Message 1 of 7
(335 Views)

First off there must be something wrong with your LV installation as Sort 1D Array is a standard LabVIEW primitive. 

 

Second you didn't attach any code or sample data.

 

Is your data in a 2D array? If so then Sort 2D Array is what you should use.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 7
(325 Views)

What version of LabVIEW are you using?  And what operation, menu operation, or series of clicks generated that popup you posted a screenshot of?

 

There was exactly one release, I believe it was 2021 32-bit, where they had removed "Sort 1D array" from the palettes.  It was still usable, you just had to either add it to the palette yourself or copy-paste it from a VI that had it already.  The replacement they put in the palette for it was a .VIM file, also named "Sort 1D array" but with extra features to sort classes that almost nobody needed, but if you opened that file then the original "Sort 1D array" was inside it in one of the cases.

 

If you're not using 2021, then either you have done something strange or you may need to repair your installation.  If you suspect a palette problem, instead of doing a complete repair you can try using the "Tools -> Advanced -> Edit Palette Set" menu option, followed by the "Restore to default" button.

 

Either way though, you need to divide your data somehow before doing the sort, or at least before doing the second sort.  Either a 2D array or a 1D array of a cluster with 2 elements.  You will then have 2 options:

 

1. Call "Sort 2D array" as suggested by RTSLVU.

2. Sort a 1D array of clusters, then split it into multiple 1D cluster arrays, then rearrange the order of the elements and sort each separate array.

0 Kudos
Message 3 of 7
(303 Views)

According to your error, it talks about a missing "object", not a missing "sort" function. Where did you get the code from? What version was it, and what version do you have? Newer LabVIEW version have the sort implemented as a VIM with extended functionality (brown icon) and that code contains "objects", but also the plain old sort 1D array, so maybe something went wrong in the down-conversion.  All you need to do is replace "sort 1D array" from the one in your palette. (If it is not there, you have bigger problems as already mentioned!)

 

Since you want to sort numerically by the first column and secondarily by the second column, "sort 2D array" might be insufficient, because it only allows one sort key row/column.

 

Here's what I would do:

 

altenbach_0-1765998875978.png

 

0 Kudos
Message 4 of 7
(277 Views)

This looks great.  Now for me to give this a try.  I see everything you have but I can't figure out what this icon is?

Rudy_01_0-1766003455510.png

 

Could you help me with that?  Or do you have the vi you could supply?

0 Kudos
Message 5 of 7
(270 Views)

"Index array" (when the input is a 2D array)

0 Kudos
Message 6 of 7
(224 Views)

@Kyle97330 wrote:

There was exactly one release, I believe it was 2021 32-bit, where they had removed "Sort 1D array" from the palettes.  It was still usable, you just had to either add it to the palette yourself or copy-paste it from a VI that had it already.  The replacement they put in the palette for it was a .VIM file, also named "Sort 1D array" but with extra features to sort classes that almost nobody needed, but if you opened that file then the original "Sort 1D array" was inside it in one of the cases.


It was 2020 SP1. https://forums.ni.com/t5/LabVIEW/Search-1D-Array-Changed-in-2020-SP1/m-p/4114744 

 

I'm with the others. If you are using LabVIEW 2021 or newer, just use the Sort 2D Array.vim after you do the Spreadsheet String To Array.



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 7 of 7
(219 Views)