menu

unnecessary-sort-comparator

Disallow comparators that reproduce the natural ordering

A comparator that only calls left.compare(right) selects the collection element's natural order. Instead, you SHOULD omit the comparator and use the natural-order overload.

Reported

1function order(values: int32[]): void {2    values.sort((left, right) => left.compare(right));3}

Accepted

1function order(values: int32[]): void {2    values.sort();3}