Thread Hash und Reihenfolge
(4 answers)
Opened by eraemien at 2011-05-01 11:38 2011-05-01T09:38:41 eraemien ändern zu: Code (perl): (dl
)
1 2 3 foreach $key (sort {$a <=> $b} keys %Elemente){ print "$key, $Elemente{$key}\n" } Das {$a <=> $b} führt zur Sortierung nach Zahlenwert. Wenn Du es weglässt, werden die Elemente alphabetisch sortiert. Editiert von FIFO: Tags repariert Last edited: 2011-05-01 19:42:18 +0200 (CEST) Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|