3 ms·
Also: what? No median-of-three pivot selection? # these lines replace "P=$1" line: local first=$1 eval local last=\${$#} eval local mid=\${$((($#+1)/2
by kazinator 12y ago
Also: what? No median-of-three pivot selection?
# these lines replace "P=$1" line:
local first=$1
eval local last=\${$#}
eval local mid=\${$((($#+1)/2))}
if [ $first -le $mid ] ; then
if [ $mid -le $last ] ; then
P=$mid
elif [ $first -le $last ] ; then
P=$last
else
P=$first
fi
else
if [ $first -le $last ] ; then
P=$first
elif [ $mid -le $last ] ; then
P=$last
else
P=$mid
fi
fi
That little enhancement blows up the LOC quite a bit. :)
- kazinator 12y agoAlso, suppose we abstract the operators a little bit: if [ $x $LT $y ] ; ... If we set LT to "-lt" we get numeric comparison. Change it to "-ot" and we can order paths by modification timestamp. Set LT to "<" and obtain lexicographic sorting on strings.