Sortieren mit Perl...
Lars Marowsky-Bree
lmb at kernel.org
Wed Jan 26 17:56:41 CET 2000
On 2000-01-26T12:32:16,
Florian Lohoff <flo at rfc822.org> said:
> Du packst dir das erstmal in ein hash ..
Geht das noch etwas ineffizienter? ;)
Erstmal einfach in ein Array:
my @lines;
while (<>) {
my @f=split(/;/o,$_);
push @lines,\@f;
}
Dann sortieren:
my @sortedlines = sort { $$a[0] cmp $$b[0]
|| $$b[1] cmp $$a[1]
|| $$b[3] cmp $$a[3] } @lines;
Ausgeben:
while (@sortedlines) {
print join(";",@$_)."\n";
}
> anstatt dem "sort" in den foreach zeilen - Dann sollte
> das reverse sein ... Ich weiss nicht inwieweit sort
> mit rationalen zahlen umgehen kann -> ausprobieren
> sonst eigene routine schreiben.
<=> für numerisch, cmp für Stringsortierung.
Mit freundlichen Grüßen,
Lars Marowsky-Brée
--
Lars Marowsky-Brée
Netzwerk Management
teuto.net Netzdienste GmbH
More information about the Linux
mailing list