rewrote which as binary search. sorting return vals of unique