in reply to Re: A generic sorting problem
in thread A generic sorting problem
anduse warnings; use strict; my @a = qw( 2 two 1 11 12 one 3abcd 6foo ); print join( " ", sort { $a <=> $b || $a cmp $b } @a ), "\n"; __END__ Argument "two" isn't numeric in numeric comparison (<=>) at c:\temp\so +rt.pl line 4. Argument "one" isn't numeric in numeric comparison (<=>) at c:\temp\so +rt.pl line 4. Argument "3abcd" isn't numeric in numeric comparison (<=>) at c:\temp\ +sort.pl line 4. Argument "6foo" isn't numeric in numeric comparison (<=>) at c:\temp\s +ort.pl line 4. one two 1 2 3abcd 6foo 11 12
#... print join( " ", sort { $a cmp $b || $a <=> $b } @a ), "\n"; __END__ 1 11 12 2 3abcd 6foo one two
Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: A generic sorting problem
by choocroot (Friar) on Jul 19, 2002 at 13:22 UTC |