[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] sorting text in human-order



sthoenna@efn.org (Yitzchak Scott-Thoennes) writes:

> In article <m2y9y2258z.fsf@rt158.private.realtime.co.uk>,
> Piers Cawley <pdcawley@bofh.org.uk> wrote:
> > sthoenna@efn.org (Yitzchak Scott-Thoennes) writes:
> > 
> > >       $srt =~ tr/0-9a-z\xe9/a-jA-ZE/;  # uc & sort nums after letters
> > 
> > `10' is going to sort before `2' with that rule. Having done the whole
> > bitter experience thing with this, may I suggest:
> > 
> >         $srt =~ s/(\d+)/unpack("B32", pack("N",$1))/eg
> 
> How about something like (untested):
> 
> s/(\d+)/printf "%0".$Config{uvsize}*2."x", $1/eg

Benchmark it? And wouldn't s/(\d+)/sprintf $fmtstr, $1/eg be quicker?

-- 
Piers



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe