>>     On Fri, Jun 8, 2018 at 6:50 PM, ToddAndMargo <toddandma...@zoho.com
>>     <mailto:toddandma...@zoho.com>> wrote:
>>
>>                 On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo
>>                 <toddandma...@zoho.com <mailto:toddandma...@zoho.com>
>>                 <mailto:toddandma...@zoho.com
>>                 <mailto:toddandma...@zoho.com>>> wrote:
>>
>>                      Hi All,
>>
>>                 https://docs.perl6.org/routine/sort
>>                 <https://docs.perl6.org/routine/sort>
>>                      <https://docs.perl6.org/routine/sort
>>                 <https://docs.perl6.org/routine/sort>>
>>
>>                      How do I fix this?
>>
>>                      $ ls | perl6 -e 'my @x=slurp(); say @x.sort'
>>                      (log.06-08-2018_16:07:39.zip
>>                      log.06-08-2018_17:07:39.zip
>>                      log.07-08-2018_06:07:39.zip
>>                      log.07-08-2018_16:07:39.zip
>>                      log.12-08-2016_06:07:39.zip
>>                      )
>>
>>
>>                      2016 should be at the top.
>>
>>
>>                      Many thanks,
>>                      -T
>>
>>
>>         On 06/08/2018 06:23 PM, Brent Laabs wrote:
>>
>>             Rename all of the input files using ISO 8601 dates.  I can't
>>             tell, from looking at those numbers, if the first field is
>>             the month or the day, so it's impossible to sort data like
>>             that with certainty.
>>
>>
>>         That is the way the files come.
>>
>>         The convention being used is
>>              month, day, year, hour, minute, second
>>
>>

>> On Fri, Jun 8, 2018 at 6:59 PM, Brent Laabs <bsla...@gmail.com
>> <mailto:bsla...@gmail.com>> wrote:
>>
>>     If possible, you should change the way the files come, or rename
>>     them when you get them, or open an issue to use a proper output log
>>     format.
>>
>>     I mean, you can sort like:
>>     @x.sort: {
>>        my $a = $^a ~~ m:g/\d+/;
>>        my $b = $^b ~~ m:g/\d+/;
>>        $a[6].defined cmp $b[6].defined
>>        ??
>>        || $a[3] cmp $b[3]
>>        || $a[1] cmp $b[1]
>>        || $a[2] cmp $b[2]
>>        || $a[4] cmp $b[4]
>>        || $a[5] cmp $b[5]
>>        || $a[6] cmp $b[6]
>>        || $a cmp $b
>>        !! $a cmp $b
>>     };
>>
>>     You could make this more efficient with a Schwartzian transform so
>>     you don't regex at every step.
>>
>>     But seriously, the problem is in the program that produces log files
>>     that are hard to sort.  Why would someone do that?

On 06/08/2018 07:00 PM, Brent Laabs wrote:
> let me revise that
>
> @x.sort: {
>    my $a = $^a ~~ m:g/\d+/;
>    my $b = $^b ~~ m:g/\d+/;
>    $a[6].defined cmp $b[6].defined
>    ??
>      $a[3] cmp $b[3]
>    || $a[1] cmp $b[1]
>    || $a[2] cmp $b[2]
>    || $a[4] cmp $b[4]
>    || $a[5] cmp $b[5]
>    || $a[6] cmp $b[6]
>    || $^a cmp $^b
>    !! $^a cmp $^b
> };
>
>

Not sure what I am looking at.  :'(

Reply via email to