07-17-2014 05:07 PM
I don't see any discernable sort order.
07-17-2014 05:18 PM
07-17-2014 05:20 PM
I just want the latest from each buch (2 or more) and if only one then itself
07-17-2014 05:26 PM - edited 07-17-2014 05:28 PM
Can you please give me an example of 10 elements that need to be sorted, I want to see a list of 10 elements unsorted and then 10 elements in sorted order. And can you also please be more specific on how you want to sort the elements? It is a pretty straightforward problem but you need to be very specific how you want to sort. You can then namely just use an standard sorting algorithm, see https://decibel.ni.com/content/docs/DOC-15272 or https://decibel.ni.com/content/docs/DOC-23241. After that you will have to create your 'own' "less then" operator. Then it should work.
07-17-2014 05:33 PM
if you get the elements on the 1st 2 squares i showed on the picture and run it you should get 2 elements output (1 of every block on the picture)
be more specific than what i have already been
lets see, many blocks (picture) on an array each block is a directory, I want to output 1 element/block the latest.
07-17-2014 05:57 PM - edited 07-17-2014 05:59 PM
Your input is: <number 1>_<number 2>_<string 1>_<number 3>_<number 4>
So <number 1> and <string 1> are static (do not change) Correct?
You first want to sort on <number 2> which is a serial number. Then you sort on <number 3> and <number 4> which are the date and time. Correct?
For example...
123_111_string_012013_120000, Date: 2013-01-20, time: 12:00:00
123_111_string_031213_120000, Date: 2013-03-12, time: 12:00:00
123_111_string_012013_115959, Date: 2013-01-20, time: 11:59:59
123_000_string_012013_120000, Date: 2013-01-20, time: 12:00:00
Should come out...
123_000_string_012013_120000, Date: 2013-01-20, time: 12:00:00
123_111_string_012013_115959, Date: 2013-01-20, time: 11:59:59
123_111_string_012013_120000, Date: 2013-01-20, time: 12:00:00
123_111_string_031213_120000, Date: 2013-03-12, time: 12:00:00
It is possible to do this using the method which I described. It is only a bit harder due to 2 main problems.
1. Your string has actually 3 dynamic parts, the serial number, the date and the time.
2. Using 01-20-2013 (month-day-year) format is the most horrible date format you could possibly choose. Please read: http://www.cowirrie.com/blog/2012/06/why-do-programmers-format-dates-using-yyyy-mm-dd/
What I would do... use my described method and implement your less then operator. In your less then operator you have the following behavior:
1. You obtain 2 strings of the format <number 1>_<number 2>_<string 1>_<number 3>_<number 4>, for ease of writing I will identify them by:
<1:1>_<1:2>_<1:3>_<1:4>_<1:5> and <2:1>_<2:2>_<2:3>_<2:4>_<2:5>, e.g., the date of string 2 is located in <2:4>.
2. You split both strings in 5 parts.
3. Then you check if <1:2> is smaller then <2:2> if that is the case you goto step 6.
4. You combine the date and time, <1:4> and <1:5> (as well as <2:4> and <2:5>) to a datetime LabVIEW format and compare them using the normal LabVIEW less then operator. If true goto step 6 else goto step 5
5. return false
6. return true
07-17-2014 05:59 PM
Wow. That VI looks WAY too complicated. Here's what I was saying to do.
07-18-2014 08:53 AM
Crossrulz,
I found 2 different discrepancies (not sure if the only ones) and they can be observed on the picture iam attaching.
Observation 1: there are two different bicycle s/n for the same name, and the program only picks latest on one (1).
Observation 2: (There is only one bicyle s/n) and sw fails to pick the latest .
regards,
07-18-2014 10:03 AM
Then edit my code. The issue is in the last loop. Change the logic for which items to keep. I just did the comparison on the name since that was what you told me to do.
I was thinking about this last night. The code current picks the oldest item for each name. The really simple solution to this is to reverse the array after doing the sort.