home *** CD-ROM | disk | FTP | other *** search
- sub numerically { $a <=> $b; }
- @sortedbynumber = sort numerically 53,29,11,32,7;
-
- sub byage {
- $age{$a} <=> $age{$b};
- }
- @sortedclass = sort byage @class;
-
- sub reverse { $b cmp $a; }
- @harry = ('dog', 'cat', 'x', 'Cain', 'Abel');
- @george = ('gone', 'chased', 'yz', 'Punished', 'Axed');
- print sort @harry;
- # prints AbelCaincatdogx
- print sort reverse @harry;
- # prints xdogcatCainAbel
- print reverse sort @harry;
- # prints xdogcatCainAbel
- print sort @george, 'to', @harry; # Remember, it's a LIST.
- # prints AbelAxedCainPunishedcatchaseddoggonetoxyz
-