For When You Can't Have The Real Thing
[ start | index | login ]
start > perl > sort dictionary by values

sort dictionary by values

Created by dave. Last edited by dave, 16 years and 176 days ago. Viewed 4,009 times. #3
[diff] [history] [edit] [rdf]
labels
attachments

Sort A Dictionary By Values

Smallest to largest:

@Keys = sort { $Hash{$a} <=> $Hash{$b} } keys %Hash;

Then iterate over @Keys.

Reverse $a and $b for largest to smallest.

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:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt