LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrange Array in ascending order by date

Kindly help me sort out the order by problem.

 

I have a date array which goes like;

 

12/3/2012

11/3/2012

12/5/2012

12/8/2012

12/6/2012

12/12/2012

12/10/2012

12/17/2012

 

I need to arrange it in ascending order, like

 

11/3/2012

12/3/2012

12/5/2012

12/6/2012

12/8/2012

12/10/2012

12/12/2012

12/17/2012

 

Please help.

Thank you in advance.

Regards
Grugh Mike

Success is Everything !!
0 Kudos
Message 1 of 25
(6,760 Views)

Hi

 

I believe you have an array of strings. Use the Sort array function available in the Arrays palette. that should sort the array in ascending order as you wanted.

 

I missed one thing. when you sort it, you would get 12/17/2012 before 12/3/2012.

hmmmm...

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 2 of 25
(6,759 Views)

sort array by ascending or decending does not give as required.

 

It gives out the result in a jumbled manner.

Regards
Grugh Mike

Success is Everything !!
0 Kudos
Message 3 of 25
(6,756 Views)

i realized it a bit before you replied.

 

anyways, can you post your code in LV2010?

 

 

 

 

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 4 of 25
(6,753 Views)

Convert the time to second and then use the sort array and then back convert to time stamp.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 25
(6,752 Views)

There is a work around, i was looking for in the forums

 

since you have the dates and not time (sicne you did not say anything about time),

 

http://forums.ni.com/t5/LabVIEW/time-date-string-to-timestamp/m-p/1644284/highlight/true#M590419

 

refer to the link below. convert the string time to timestamp. you can use a constant time with all values.

then covnert the timestamp to double number, sort the array in ascending order.

 

then convert the numeric time value to string and extract only the date info.

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 6 of 25
(6,751 Views)

is'nt there any easier method to sort a time array ?

Regards
Grugh Mike

Success is Everything !!
0 Kudos
Message 7 of 25
(6,747 Views)

This is one of the method to sort the array.

 

Date-timearray.png

-----

The best solution is the one you find it by yourself
Message 8 of 25
(6,738 Views)

@Grugh_Mike wrote:

is'nt there any easier method to sort a time array ?


It's a lot easier than trying to manipulate the strring into yyyy/dd/mm format and sorting alphabetically.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 25
(6,693 Views)

Well that sort of depends, if the code that generates the timestamp in the first place is under your control, just generate it in that order to begin with.


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 10 of 25
(6,690 Views)