On 08/23/2012 09:10 AM, Uri Guttman 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.
I don't thing so. I am comparing two modules that generate sorters. The may have different APIs, but at the functional level they are the same thing. > 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. Actually Sort::Key provides both, you can choose between the Sort::Key::Maker declarative API that allows to create multi-key sorting subs and the prebuild mono-key sorters from Sort::Key (and also, the jit-build multi-key sorters of Sort::Key::Multi). > having a single sub with a flexible api is a much better interface. Well, it depends, the flexible API of Sort::Maker results in code that's probably more legible and easy to understand without reading the module documentation first. On the other hand, using the pre-build sorters from Sort::Key results in more concise and simpler code. If you need to include sorting operations in your code frequently you get to appreciate that. > 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. IIRC, a long time ago I send you a patch for Sort::Maker benchmarking script incorporating Sort::Key variants that showed how faster my module can be. I would try to find it and send it to you again. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/