tweak to avoid out-of-bounds access in sort.c