summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-28 16:40:00 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-28 16:40:00 +0000
commitbce512bc41bf288fc6f94d3e092f525dd8541345 (patch)
tree021a32939dd6b8f6f25a43b1f00176eb80a69a3f /MDK
parentc1ce79a112218c16ae4d8b15a00038dcc5d55066 (diff)
downloadperl-MDK-Common-bce512bc41bf288fc6f94d3e092f525dd8541345.tar
perl-MDK-Common-bce512bc41bf288fc6f94d3e092f525dd8541345.tar.gz
perl-MDK-Common-bce512bc41bf288fc6f94d3e092f525dd8541345.tar.bz2
perl-MDK-Common-bce512bc41bf288fc6f94d3e092f525dd8541345.tar.xz
perl-MDK-Common-bce512bc41bf288fc6f94d3e092f525dd8541345.zip
MDK::Common::DataStructure: add sort_numbers
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common/DataStructure.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/MDK/Common/DataStructure.pm b/MDK/Common/DataStructure.pm
index f139555..0becc8d 100644
--- a/MDK/Common/DataStructure.pm
+++ b/MDK/Common/DataStructure.pm
@@ -10,6 +10,10 @@ MDK::Common::DataStructure - miscellaneous list/hash manipulation functions
=over
+=item sort_numbers(LIST)
+
+numerical sort (small numbers at beginning)
+
=item ikeys(HASH)
aka I<sorted integer keys>, as simple as C<sort { $a E<lt>=E<gt> $b } keys>
@@ -106,10 +110,11 @@ use MDK::Common::Func;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK);
@ISA = qw(Exporter);
-@EXPORT_OK = qw(ikeys add2hash add2hash_ put_in_hash member invbool listlength deref deref_array is_empty_array_ref is_empty_hash_ref uniq difference2 intersection next_val_in_array group_by2 list2kv);
+@EXPORT_OK = qw(sort_numbers ikeys add2hash add2hash_ put_in_hash member invbool listlength deref deref_array is_empty_array_ref is_empty_hash_ref uniq difference2 intersection next_val_in_array group_by2 list2kv);
%EXPORT_TAGS = (all => [ @EXPORT_OK ]);
+sub sort_numbers { sort { $a <=> $b } @_ }
sub ikeys { my %l = @_; sort { $a <=> $b } keys %l }
sub put_in_hash { my ($a, $b) = @_; while (my ($k, $v) = each %{$b || {}}) { $a->{$k} = $v } $a }
sub add2hash { my ($a, $b) = @_; while (my ($k, $v) = each %{$b || {}}) { $a->{$k} ||= $v } $a }