Separate _.uniq isSorted logic to a helper