Stable sorting with O(sqrt(N)) external memory