in reply to Sort array1 according to sorting of array2
use strict; my (@arr1); $arr1[0] = "john:::10"; $arr1[1] = "bill:::9"; $arr1[2] = "mary:::35"; $arr1[3] = "willy:::21"; ##################### sub comparesimple { (split /:/,$a)[-1] # Take last element of split.. <=> # Do numeric compare (split /:/,$b )[-1] } ############################## print qq($_ \n) for sort comparesimple @arr1;
Earth first! (We'll rob the other planets later)
|
|---|