Home > @rushstack/node-core-library > Sort > sortSet
Sort.sortSet() method
Sorts the entries in a Set object. The result is guaranteed to be a stable sort.
Signature:
static sortSet<T>(set: Set<T>, comparer?: (x: T, y: T) => number): void;
Parameters
Parameter | Type | Description |
---|---|---|
set | Set<T> | |
comparer | (x: T, y: T) => number | (Optional) |
Returns:
void
Example
let set: Set<string> = new Set<string>();
set.add('zebra');
set.add('goose');
set.add('aardvark');
Sort.sortSet(set);
console.log(Array.from(set)); // ['aardvark', 'goose', 'zebra']