Re: [PBML] Re: explanation needed on sort using {$a<=>$b}

2001-11-12 Thread EternalLifeThereAfter
rint "Unsorted nos => @a\n"; print '*'x 30,"\n"; my @b = sort spaceship3 @a; sub spaceship3 { $count3++; print "$count3 \$a = $a whilst \$b = $b , value \= ", $a<=>$b ; print " Stay\n" if (($a<=>$b) == 1 || ($a&

Re: explanation needed on sort using {$a<=>$b}

2001-11-12 Thread EternalLifeThereAfter
st $b = 44 $a = 34 whilst $b = 35 $a = 2 whilst $b = 12 $a = 0 whilst $b = 12 $a = 0 whilst $b = 2 0,2,12,14,34,35,44 - Original Message - From: "Jonathan E. Paton" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, November 11, 200

Re: explanation needed on sort using {$a<=>$b}

2001-11-11 Thread Jonathan E. Paton
> @a= qw (68 3 5 67 54 23 69 ); > > @b = sort {-1} @a; ### what happens here ! > results = 5,3,68,67,69,23,54 > Hey look, its reversed the order of the numbers either side of the number 67! Extremely useful :P You shouldn't use this sort, since it breaks for other quantities of numbers. > @c

explanation needed on sort using {$a<=>$b}

2001-11-11 Thread eventualdeath
@a= qw (68 3 5 67 54 23 69 ); @b = sort {-1} @a; ### what happens here ! results = 5,3,68,67,69,23,54 @c = sort {$a<=>$b} @a; ### what happens here ! results = 3,5,23,54,67,68,69 I know that sort by default sort in ascii order, I wanted to know what exactly happens to the "spaceship" operator.