Piers Cawley <[EMAIL PROTECTED]> writes:
> "David L. Nicol" <[EMAIL PROTECTED]> writes:
> > Marc Lehmann wrote:
> > >
> > > On Sat, Dec 30, 2000 at 05:31:29AM +0000, "David L. Nicol"
><[EMAIL PROTECTED]> wrote:
> > > > I do not know exactly what the perl5 default sort heuristic is,
> > > > aside that it tries to DWIM both numeric and string data.
> > >
> > > There is no heuristic, the default is simply $a cmp $b, so I am
> > > not sure what you mean with DWIM ;)
> >
> > I was wrong. If it did a crowley/schwartz transform, it would DWIM.
> >
> > That is what I am proposing: that perl6 _sort_ do, by default, an
> > implied crawley/schwartz transform.
>
> That's 'Cawley'. And I really don't think it would be a good idea. At
> all.
Further to that, nor do I think the technique deserves to be given a
new name, all I did was apply something from the Cookbook to the
problem. And on further reflection, I find myself wondering if
something like:
s/(\d+(?:\.\d+))/sprintf("%010g", $1)/eg
wouldn't be quicker anyway.
And for 'proper' library type sorting (assuming all works are in
English) we should really be doing something like:
require Lingua::EN::Numbers;
s/(\d+(?:\.\d+))/Lingua::EN::Numbers->($1)->get_string/eg;
since in a library numbers get sorted based on how they are spoken
based on the language of the work in whose title they appear. Whilst
library card order is somewhat weird to a computer scientist, it is
the default order used in at least one real world.
--
Piers