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

Re: [FWP] sorting text in human-order



Ian Phillipps <igp_list2@tesco.net> writes:

> On Thu, 30 Nov 2000 at 09:16:06 +0000, Piers Cawley wrote:
> > 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
> Which isn't the way I'd expect - lists like phonebooks in UK are sorted
> numbers first.

Indeed. And libraries sort numbers as words.

> > > >         $srt =~ s/(\d+)/unpack("B32", pack("N",$1))/eg
> > > How about something like (untested):
> > > s/(\d+)/printf "%0".$Config{uvsize}*2."x", $1/eg
> 
> In a blackholed posting to the list, I suggested
> 	s/\d+/ "\01".pack 'w',$& /ge
> where the "\01" serves to place the numbers before the sort; put in a
> big character to sort later.

I have the distinct recollection that BER numbers didn't sort
correctly under ASCII. However, I may be completely and utterly mad.

-- 
Piers


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