| ![]() |
Far More Than Everything You've Ever Wanted
to Know About Sorting
In comp.lang.perl, Randal Schwartz <[email protected]> obfuscates:
>>>> "Hugo" == Hugo Andrade Cartaxeiro <[email protected]> writes: : :Hugo> print $str; :Hugo> eir 11 9 2 6 3 1 1 81% 63% 13 :Hugo> oos 10 6 4 3 3 0 4 60% 70% 25 :Hugo> hrh 10 6 4 5 1 2 2 60% 70% 15 :Hugo> spp 10 6 4 3 3 1 3 60% 60% 14 : :Hugo> and I like to sort it with the last field as the order key. I know : :Hugo> perl has some features to do it, but I can't make 'em work properly. : :Well, speaking Perl with a Lisp.... :-)
We all recall that Perl est un esprit LISP dans un corps C, n'est-ce pas? :-) (``corps C'' sounds like
``corset'' in French.)
CODE 0.0
:require 5; # if you don't have perl 5 by now, why NOT? :-)
:$str =
: join "
",
: map { $_->[0] }
: sort { $a->[1] <=> $b->[1] }
: map { [$_, (split)[-1]] }
: split /
/,
: $str;
:
:Hugo> Reply by mail (if any).
: :(oops :-)
Oh for cryin' out loud, Randal! You expect a new perl programmer to make heads or tails of that>? :-)
You're postings JAPHs for solutions, which isn't going to help a lot. You'll probably manage to scare
these poor people away from the language forever? :-)
BTW, you have a bug.
Couldn't you at least indent it properly? :-) This might help folks make more sense of it. I'm going to
use the
map EXPR,LIST
rather and then