Tested and fixed merge sort bugs when there are duplicate rows