This implementation includes the optimizations described in chapter 6.4.2 to improve the internal cost the the sort.