Open gordonwoodhull opened 4 years ago
If the predicate is specified, it would have precedence over the ordering accessor.
Currently we have
This could be
_computeOrderedGroups (data) {
// clone the array before sorting, otherwise Array.sort sorts in-place
const defaultPredicate = (a, b) => this._ordering(a) - this._ordering(b);
return Array.from(data).sort(_orderPredicate || defaultPredicate);
}
and then add a getter/setter orderPredicate
.
How you thought anymore about implementing something like this. I have a mixed case of keys and would like to sort by case insensitive order.
An example of my keys are:
all, Anyone, lightning, Thunder
The order in the html-legend is:
Anyone, Thunder, all, lightning
It should be easy - want to give it a shot?
Case insensitivity would be an excellent test case.
Just don’t read #1161 - that made it sound much too complicated. It should just be the one line change above.
Now that we are using built-in Array.sort, we could expose an ordering predicate instead of only .ordering().
.ordering()
makes it difficult to sort descending, for example.This replaces #1161, which I overexplained and made too complicated.