use Data::Dumper; WITHOUT_USING_SPACESHIP: { my @array = qw( 7 100 12 1 4 2 88 007 ); @array = sort { $a>$b ? 1 : -1 } @array; print Dumper \@array; } WITHOUT_USING_SORT_AT_ALL: { my @array = qw( 7 100 12 1 4 2 88 007 ); for my $i (0 .. $#array) { for my $j ($i .. $#array) { @array[$i, $j] = @array[$j, $i] if $array[$i] > $array[$j] +; } } print Dumper \@array; }
What sorting algorithm is that? I can never remember their names. It may be bubble sort.
In reply to Re: Numeric sorting WITHOUT <=>
by tobyink
in thread Numeric sorting WITHOUT <=>
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |