Faster again. Now uses less memory than StatsBase version.
-
Rewrote
insertionsort!
andmergesort!
by copy-paste-edit from the relevant methods ofsort!
in base/sort.jl. Upshot was further speed improvements and reduction in memory footprint. The function now allocates 30% to 40% less memory than the StatsBase version.In the case of
insertionsort!
it might be possible to usesort!
instead, but with a custom!isless(x,y)
and that would avoid the unpleasant code duplication. But in the case ofmergesort!
I don't think that is possible as the function!isless
would not "know" by how much to increase the swaps counter.Note that
StatsBase.corkendall
can also be criticised for for code duplication. It contains the mergesort algorithm in disguise as the functionswaps!
. -
Moved function
corkendallnaive
to the tests folder.