Well, who can tell? You only gave us the results of the benchmark, not what you actually tested - neither the code, nor the input.
yeah, sorry.. Now deleted the code, so I can't post exactly what I benchmarked, but it was just an array of 200 or so 4 digit integers. The code was as basic as I could make it.
something like:
use Benchmark;
my @array = (6252,8278, ...array of 200 4 digit integers...;
timethese(0, {
sorty => \&sorty,
space => \&spaceship,
comp => \&comp
});
sub sorty {
return sort @array
}
sub comp {
return sort {$a cmp $b} @array
}
sub spaceship {
return sort {$a <=> $b} @array
}
## gives:
Benchmark: running comp, sorty, space, each for at least 3 CPU seconds
+...
comp: 2 wallclock secs ( 3.05 usr + 0.02 sys = 3.07CPU) @ 617
+076.87/s (n=1894426)
sorty: 1 wallclock secs ( 3.06 usr + -0.00 sys = 3.06CPU) @ 650
+267.65/s (n=1989819)
space: 3 wallclock secs ( 3.38 usr + 0.02 sys = 3.40CPU) @ 590
+187.65/s (n=2006638)
I was just surprised that sorting using cmp was not much slower than <=>; for .. I realise now that I just hadn't thought about it too much (heavy weekend), and if I had, I probably wouldn't have had a preconcieved idea about the relative speeds..(fiddling with the sizes of the integers, making them 1-16 digits long doesn't have much effect on the relative (or actual) speed of the sorts, either, btw).
I shall just use
sort on its lonesome, I think.