LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sort array in respect to time

Hello,

 

i would like to know how to sort an 2-D Array or an Multicolumn Listbox. My first column is the the time column. The second column is the Event column and  the third column is the Switch column. I know how to sort a 2-d array or an Multicolumn Listbox ascending or descending. But i want to sort it in respect to the actuall time. Attached youu can find an example.

 

 

The Time when this was sorted by hand was 16:00 or 4PM.

The time 900 means 9:00 AM.

I'm using labview 2010.

I hope you can understand what i want to do. Maybe someone can give me some help!

If you have any question just tell me

Thanks,

 

Elvis

 

0 Kudos
Message 1 of 16
(3,616 Views)

You said you know how to sort a 2D array or a multicolumn listbox, so what is your specific issue? Is the second picture the result of the sort? Did you write your own code for sorting? Are you perhaps using OpenG's Sort 2D Array functions? Are you having a problem because you're dealing with strings (referring to the ItemNames property for the listbox)?

0 Kudos
Message 2 of 16
(3,591 Views)

By default, strings are sorted alphabetically (e.g. 11 before 5), while you apparently want a numeric sort.

 

have a look here (check the "true" case in the attached example).

Message 3 of 16
(3,581 Views)

yes the second picture is the result of the sort. I know the openG's Sort 2 Array. But I want to sort the Time in respect to the current time. The example should show if the current time is 4 pm the next time in the listbox would be 22:00 or 10pm and after that 1:00. I want to use this for a clock timer!  So the common sort vi's don't do this. I need something like an algorithm

0 Kudos
Message 4 of 16
(3,570 Views)

Did you try the example I linked above?

Message 5 of 16
(3,567 Views)

yes i did. If would use this with my listbox.  1:00 would be in the first row and 22:00 or 10PM in the last row. But i wan't that the first row is allways the time which is the closest time to the current time... do you understand my issue? 

 

 

Thanks for your help!!!

0 Kudos
Message 6 of 16
(3,561 Views)

So you want the newest time on top? Simply reverse the sort keys.

0 Kudos
Message 7 of 16
(3,552 Views)

@elvis21z wrote:

yes i did. If would use this with my listbox.  1:00 would be in the first row and 22:00 or 10PM in the last row. But i wan't that the first row is allways the time which is the closest time to the current time... do you understand my issue?


I'm not sure if we fully understand what you are saying here. My interpretation is that you did not wire it correctly, because based on your original picture, the sort works:

 

 

 

If that is not what you want, the please provide an exact indication of what the output should be.

0 Kudos
Message 8 of 16
(3,546 Views)

see picture attached

 

The sorted listbox should look like the right one (Sorted by time). The current Time is 18:00 (6PM). The next time when something should happen is 22:00 (10PM). That's the reason why 2200 is in the first row.

Download All
0 Kudos
Message 9 of 16
(3,535 Views)
Your table currently has no information about the current time. If you have it from elsewhere, subtract the current time and rotate (and possibly reverse) the sort key accordingly.
0 Kudos
Message 10 of 16
(3,518 Views)