Materialises source into a sorted set of distinct elements.
Type of elements within source.
The source iterable.
Optional
Optional order comparator used to sort the elements.
A sorted set containing the distinct elements from source.
The entire sequence is enumerated immediately and duplicate elements are collapsed using the set's ordering semantics.
const numbers = [3, 1, 4, 1, 5, 9, 2, 6];const sortedSet = toSortedSet(numbers);console.log(sortedSet.toArray()); // [1, 2, 3, 4, 5, 6, 9] Copy
const numbers = [3, 1, 4, 1, 5, 9, 2, 6];const sortedSet = toSortedSet(numbers);console.log(sortedSet.toArray()); // [1, 2, 3, 4, 5, 6, 9]
Materialises source into a sorted set of distinct elements.