Skip to main content

What it flags

Calling sort() or toSorted() on a numeric array without a comparator orders its numbers as strings. For example, 10 sorts before 2. The finding appears with --include-contextual.

How to review or fix

Confirm the intended order before choosing a comparator. Consider how to order NaN if it can appear. Numeric typed arrays use a numeric default order.