-----Original Message----- >From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]> >Sent: Aug 21, 2007 12:32 PM >To: Jeff Pang <[EMAIL PROTECTED]> >Cc: beginners@perl.org >Subject: Re: regex help > >Jeff Pang wrote: >> use strict; >> use warnings; >> >> my @arr = qw(14-special.4-32 >> 14-special.4-32 >> 14-special.4-33 >> 14-special.4-33 >> 15-special.1-51 >> 15-special.1-51 >> 15-special.1-52 >> 15-special.1-52 >> 15-special.1-52 >> 15-special.1-53 >> 15-special.1-53 >> 15-special.1-53 >> 15-special.1-54 >> 15-special.1-54 >> 15-special.3-44 >> 15-special.3-44 >> 15-special.3-45 >> 15-special.3-45 >> 15-special.4-4 >> 15-special.4-4 >> 15.2-100 >> 15.2-100 >> 15.2-104 >> 15.2-104 >> 15.2-124 >> 15.2-124 >> 15.2-65 >> 15.2-65 >> 15.2-66 >> 15.2-66); >> >> my @new = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { >> [$_,(split/-/)[-1]] } @arr; >> print "@new[0..4]"; > >Fails; this would put '15-special.3-45' before '15-special.1-51' >
Well,have you tested the codes then said this? I sort it based on the last number field splited by '-'.It works fine for me. -- Jeff Pang - [EMAIL PROTECTED] http://home.arcor.de/jeffpang/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/