Thread Array-Sortierung nach vorgegebenen Mustern? (2 answers)
Opened by toby at 2008-09-12 17:48

pq
 2008-09-12 17:56
#114573 #114573
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
Code (perl): (dl )
1
2
3
4
5
6
7
my @sorted = map {
    $_->[1]
} sort {
    $a->[0] <=> $b->[0] || $a->[1] cmp $b->[1]
} map {
    [tr/-// ? 0 : tr/_// ? 1 : 2, $_]
} @array;

nennt sich http://en.wikipedia.org/wiki/Schwartzian_transform
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread Array-Sortierung nach vorgegebenen Mustern?