Thanks to all that offered help - much appreciated .. examples work ..more for me to learn...
Rob If you could explain how this works, especially how $a $b are set with the compare values my @sorted = sort { (split ':', $a)[-1] <=> (split ':', $b)[-1] } @array; Thanks "Rob Dixon" <[EMAIL PROTECTED] To: [EMAIL PROTECTED] am.co.uk> cc: Subject: Re: sorting thoughts 29/01/03 20:03 "Steven Massey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] m... > Hi > > just about to embark on a sorting routine, and I thought before I spend > ages(at my ability) I would see what thoughts you guys have on this. > > I have an array, each line contains fields seperated by ":" > I want to sort the array numerically ascending by the last field. > Hi Steven This will work. Let us know if you want the code explaining. Thanks to Ed for his people. my @array = qw( fred:lucy:24 john:jane:10 frank:mary:5 rupert:cindy:16 ); my @sorted = sort { (split ':', $a)[-1] <=> (split ':', $b)[-1] } @array; print "$_\n" foreach @sorted; Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]