Merge sort (optimizations)