less lazy uniquely_sorted, still not perfect, but works without using sort or uniq