For When You Can't Have The Real Thing
[ start | index | login ]
start > perl > simple numeric sort

simple numeric sort

Created by dave. Last edited by dave, 19 years and 100 days ago. Viewed 3,752 times. #1
[edit] [rdf]

Simple Numeric Sort


foreach $item (sort(keys(%Dictionary)))


foreach $item (sort { $a <=> $b } keys (%Dictionary))

The first example does a string sort, so in this case you can end up with sequences which look like

  • 1 2 3 44 5
The second example returns the correct order.
no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful: | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt