TypeScript sorting an array

The error is completely correct.

As it’s trying to tell you, .sort() takes a function that returns number, not boolean.

You need to return negative if the first item is smaller; positive if it it’s larger, or zero if they’re equal.

Leave a Comment