Seperate uniq isSorted logic into helper