Re: sort using <=>

2004-08-13 Thread Gunnar Hjalmarsson
ou want to sort by, you should do a lexical sort (using cmp), not a numerical sort (using <=>). Finally you can print whichever fields you like. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMA

sort using <=>

2004-08-13 Thread DBSMITH
hello perl , I am trying to sort a data file on field 3 that looks like: 08/09/0411:02:43E4 08/09/0411:02:43E01220 08/09/0411:02:43E00820 08/09/0411:02:43E01001 08/09/0411:02:43E00712 08/09/04

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.