取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 16 条)
3,833 次查看

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 项奖励
2 条消息(共 16 条)
3,808 次查看

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).

3 条消息(共 16 条)
3,798 次查看

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 项奖励
4 条消息(共 16 条)
3,787 次查看

Did you try the example I linked above?

5 条消息(共 16 条)
3,784 次查看

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 项奖励
6 条消息(共 16 条)
3,778 次查看

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

0 项奖励
7 条消息(共 16 条)
3,769 次查看

@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 项奖励
8 条消息(共 16 条)
3,763 次查看

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.

下载全部
0 项奖励
9 条消息(共 16 条)
3,752 次查看
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 项奖励
10 条消息(共 16 条)
3,735 次查看