Tie::SortHashPerl module to keep hashes in a sorted order | |
Download |
Tie::SortHash Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Casey Tweten
- Publisher web site:
- http://search.cpan.org/~ctweten/
Tie::SortHash Tags
Tie::SortHash Description
Perl module to keep hashes in a sorted order Tie::SortHash is a Perl module to keep hashes in a sorted order.SYNOPSIS use Tie::SortHash; my %people = ( 'John Doe' => 33, 'Jane Doe' => 29, 'Jim Smith' => 15, ); my $sortblock = q( my $c = (split /s+/, $a); my $d = (split /s+/, $b); $c cmp $d || $hash{$a} $hash{$b} ); tie %people, 'Tie::SortHash', \%people, $sortblock; foreach my $name ( keys %people ) { print $name . " is " . $people{$name} . " years old. "; } # This output will always be Jane Doe is 29 years old. John Doe is 33 years old. Jim Smith is 15 years old.This module is a designed to be a light weight hash sorting mechanism. It is often frustrating to have a hash return elements in a random order, such as when using the keys(), values() and each() functions, or simply when iterating over them. Requirements: · Perl
Tie::SortHash Related Software