Home > @microsoft/node-core-library > Sort > sortSet

Sort.sortSet() method

Sorts the entries in a Set object according to the keys.

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  

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']