See https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf
Sorting continued
Sample Algorithms using stack<>