Front page | perl.riscos |
Postings from July 2004
Re: Sorting
Thread Previous
From:
Derek.Moody
Date:
July 2, 2004 19:58
Subject:
Re: Sorting
Message ID:
Marcel-1.53-0703025659-0b0BxcK@half-baked-idea.co.uk
On Thu 01 Jul, Colin Foster wrote:
> I'm sorting a list in numerical order using
> @new = sort {$b <=> $a} @old;
>
> Is it possible to restrict the sort so that it only sorts on the first
> 4 digits.
Presuming your data are well regulated try:
@new = sort {substr($b,0,4) <=> substr($a,0,4)} @old;
(Following your $b $a count-down order)
Cheerio,
--
>> derek.moody@clara.net
Thread Previous
-
Sorting
by Colin Foster
-
Re: Sorting
by Derek.Moody