in reply to Re: Sort the array
in thread Sort the array

Hi,

your solution works fine. But Can you explain the line a but more ,

my @theSortedList = sort { $a <=> $b } @theList;

Since i m new to Perl, i did not understood what its actually doing.
Thanks,
Shekar

Replies are listed 'Best First'.
Re^3: Sort the array
by jwkrahn (Abbot) on Nov 10, 2008 at 11:53 UTC

     <=> is a numeric equality operator.   See perlop for details.    $main::a and  $main::b are special variables that sort uses internally.   So the code block is a call-back subroutine that sort uses to compare the values of the incoming list.