truthseeker66 has asked for the wisdom of the Perl Monks concerning the following question:
I see a line, "@sorted = sort {$a <=> $b} @array;"
The text book I read says, "When you need to sort data in
numerical order, you have to add an argument to the sort
statement.
What confuses me is '$a <=> $b'.
Could you explain what this line do? Can I use '$c <=> $d'
instead?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $a <=> $b
by roboticus (Chancellor) on Oct 09, 2012 at 18:18 UTC | |
|
Re: $a <=> $b
by tobyink (Canon) on Oct 09, 2012 at 18:57 UTC | |
|
Re: $a <=> $b
by GrandFather (Saint) on Oct 10, 2012 at 01:31 UTC |