Skip Menu |

This queue is for tickets about the Hash-MoreUtils CPAN distribution.

Report information
The Basics
Id: 40744
Status: resolved
Priority: 0/
Queue: Hash-MoreUtils

People
Owner: Nobody in particular
Requestors: rossiya2 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.02



Subject: hashsort
Date: Fri, 7 Nov 2008 05:40:23 -0800
To: bug-Hash-MoreUtils [...] rt.cpan.org
From: "m c" <rossiya2 [...] gmail.com>
Hello I made hashsort work better with prototypes sub hashsortt(&\%) { my ($code, $hash) = @_; unless ($hash) { $hash = $code; $code = sub { $a cmp $b }; } return map { ($_ => $hash->{$_}) } sort { $code->() } keys %$hash; } x hashsortt { $a cmp $b } %hash; 0 'af' 1 88 2 'f' 3 1 4 'kf' 5 3 6 'zf' 7 5 %rHash = reverse %hash x hashsortt { $a <=> $b } %rHash; 0 1 1 'f' 2 3 3 'kf' 4 5 5 'zf' 6 88 7 'af' Probably still does a copy. I used the code in List::MoreUtils::pairwise for scaffolding
Prototype would forbid default sort block. I tried to add a few words more in documentation to clarify.
0.02 uploaded and in CPAN