Sorting is a very expensive way of finding duplicates. The simplest algorithm for finding duplicates is to compare every element with every other element - like a bubble sort
, but without the swaps.
There is a quicker way of spotting duplicates, which is to drop a copy or representation of each object in the vectors into a sorted list. On each drop, check if the object already exists, and if it does then there's your duplicate.