Tie::Array::SortedAn array which is kept sorted | |
Download |
Tie::Array::Sorted Ranking & Summary
Advertisement
- License:
- GPL
- Price:
- FREE
- Publisher Name:
- Tony Bowden
- Publisher web site:
- http://search.cpan.org/~sri/
Tie::Array::Sorted Tags
Tie::Array::Sorted Description
An array which is kept sorted Tie::Array::Sorted is a Perl module that presents an ordinary array, but is kept sorted. All pushes and unshifts cause the elements in question to be inserted in the appropriate location to maintain order.Direct stores ($a = "wibble") effectively splice out the original value and insert the new element. It's not clear why you'd want to use direct stores like that, but this module does the right thing if you do.If you don't like the ordinary lexical comparator, you can provide your own; it should compare the two elements it is given. For instance, a numeric comparator would look like this: tie @a, "Tie::Array::Sorted", sub { $_ $_ }Whereas to compare a list of files by their sizes, you'd so something like: tie @a, "Tie::Array::Sorted", sub { -s $_ -s $_ }SYNOPSIS use Tie::Array::Sorted; tie @a, "Tie::Array::Sorted", sub { $_ $_ }; push @a, 10, 4, 7, 3, 4; print "@a"; # "3 4 4 7 10" Requirements: · Perl
Tie::Array::Sorted Related Software