There is no sorting algorithm that is O(n log n) in time, O(1) in space and also stable. Pick your poison.