Re: Sorting
[email protected] ("Derek.Moody") Sat, 3 Jul 2004 03:56:59 +0100 (BST)
| Newsgroups | perl.riscos |
|---|---|
| Message-ID | <[email protected]> |
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,
--
>> [email protected]