Generic table sort algorithm.
Calculate unique polygon edges.