On Thu, Aug 23, 2012 at 9:10 AM, Uri Guttman <u...@stemsystems.com> wrote:
> On 08/23/2012 02:54 AM, Salvador Fandino wrote: > > >>> It's a pity Sort::Maker not in Debian >>> >> >> There is also Sort::Key, available in Debian testing and unstable, and >> which is usually faster than Sort::Maker and also Sort::Key::Radix, even >> faster when sorting by numeric keys but not available in Debian. >> >> use Sort::Key qw(ukeysort); >> >> my @sorted = ukeysort { /^(\d+)-(\d+)/ >> or die "bad key $_"; >> $1 * 100 + $2 } @data; >> >> >> The 'u' prefix in 'ukeysort' specifies that the sorting key is an >> unsigned integer. >> > > you are comparing apples and oranges. your module provides numerous > specialized sort subs (like php does) which means the coder has to remember > or lookup what each one does. i counted at least 32 similarly names subs > which is very confusing. having a single sub with a flexible api is a much > better interface. > > your claim for it being faster needs backing with benchmarks with multiple > keys. single key sorts are fast with just the sort function as is. since > your multikey sorts must use a map/sort/map method, again showing how they > are faster then the GRT would be interesting. > > uri > > > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > As said before is all needs benchmarking to see what is really faster and how much faster actually (a 1% increase in time but a much easier interface or far less dependencies could be preferable in some cases). If I had to deal with this I would probably use the map, sort, map solution proposed before as this solution is available on all platforms and therefore highly portable (in the environment I work in there is a range of perl versions from 5.005 to the latest release on a wide range of operating systems) As for faster or slower, have a look at the size of the hash you are sorting, if the hash only has a few hundred keys the speed difference might not even be noticeable (a few ms more or less in a long running process is not going to be noticed). On the other hand is there is tens of thousands of keys and the sorting time is reduced an awful lot with this sort being the main time consumer within the overall process... It might be worth installing the module even if it is a slightly painful thing in some environments. Regards, Rob