[PD-457] Sorting fix #840 

Just wrapped the results in a set to remove duplicates. Originaly went for a more efficient query, but technical constraints prevented that version from panning out.