1 2 3 4 5
my @sdata = map $_->[0], sort { $b->[1][2] <=> $a->[1][2] or # year $b->[1][1] <=> $a->[1][1] or # month $b->[1][0] <=> $a->[1][0] } # day map [$_, [split /\//, $_->{date}]], @data;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/perl use strict; use Data::Dumper; # create dummy array with 1000 fields my @data = map { text => "text$_", name => "name$_", head => "head$_", date => sprintf "%02d/%02d/%02d %02d:%02d:%02d", 0+rand 30, 1+rand 12, 1+rand 10, 0+rand 23, 0+rand 59, 0+rand 59 }, 1..10000; # sort the data in the array by date my @sdata = map $_->[0], sort { $b->[1][2] <=> $a->[1][2] or # year $b->[1][1] <=> $a->[1][1] or # month $b->[1][0] <=> $a->[1][0] or # day $b->[1][3] <=> $a->[1][3] or # Stunde $b->[1][4] <=> $a->[1][4] or # Minute $b->[1][5] <=> $a->[1][5] # Sekunde } map [$_, [split m{[/: ]}, $_->{date}]], @data; # dump the sorted data print Data::Dumper->Dump([\@sdata], ['*sdata']);
2011-11-03T08:19:03 XertnoCode (perl): (dl )1 2 3 4 5 6 7 8 9 10 11# sort the data in the array by date my @sdata = map $_->[0], sort { $b->[1][2] <=> $a->[1][2] or # year $b->[1][1] <=> $a->[1][1] or # month $b->[1][0] <=> $a->[1][0] or # day $b->[1][3] <=> $a->[1][3] or # Stunde $b->[1][4] <=> $a->[1][4] or # Minute $b->[1][5] <=> $a->[1][5] # Sekunde } map [$_, [split m{[/: ]}, $_->{date}]], @data;
Was ich noch nicht ganz verstehe warum bei $b->[1][5] noch die [1] steht.