Time and space complexity comparison of sorting algorithm