For instance:
{2,3},{1,2},(2,2},{3,1},{2,1} to {1,2},{2,1},{2,2},{2,3},{3,1}
That's what I think:
Do a merge sort in the first column of values. Scroll through the set to see if there are duplicate values ββin the first column. If there is, paste them into the list.
Combine the sorting of this list in the second column, and then combine them into the main set. Although this seems practical, it seems too complicated. This should work in O(NlogN) , so if anyone can think of a faster / same complexity algorithm, which is also easier, submit it!
Thanks!
source share