Closed vanodevium closed 1 year ago
Try this:
class DescSortedArray extends SortedArray {
static compare(a, b) {
return b - a > 0 ? 1 : -1;
}
}
The comparator (SortedArray.compare
) return type is -1 | 0 | 1
and returning other values throws it off.
@zandaqo Thanks for help! Maybe it would be nice to write this in the readme as a note?
Is it normal to see an unsorted array?
Is there any chance to enable auto sort when I call push() or I have to call sort() after all push() calls?
Thanx!