----- Original Message ----- 
From: "Chris Wagner" <[EMAIL PROTECTED]>
To: <perl-win32-users@listserv.ActiveState.com>
Sent: Sunday, December 18, 2005 9:26 AM
Subject: Re: Sort question


> I'm a little amazed this works but it does. :)
>
> @nums = qw(55_20051202 56_20051203 57_20051204 101_20051205 59_20051206
> 10_20051207 61_20051208 62_20051208 63_20051208 64_20051209 65_20051209
> 66_20051210 67_20051211 68_20051212 69_20051213 70_20051214);
> print join "\n", (map {join "_", @{$_}} (sort {${$a}[0] <=> ${$b}[0]} map
> {[split /_/]} @nums ));
>

That's perhaps a little obfuscated. All that's necessary is:

print join "\n", sort {$a <=> $b} @nums;

That assumes that each number before the underscore is unique (no repeats).
>From the OP's original description (and from the numbers provided), I think
that's the case. My understanding is that he was sorting based solely on the
value of the number before the underscore - which is precisely what 'sort
{$a <=> $b} @nums' does, in this instance.

Cheers,
Rob

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to