allow specifying ordering algorithm, e.g. descending?
See original GitHub issueFiling this question as a placeholder, in case anyone wants this. I’ve run into it twice, but in weird/unique circumstances, and I don’t think I’ve heard anyone else ask about it.
Capped charts (pie, row) and ordinal coordinate grid charts use baseMixin.ordering
and crossfilter.quicksort.by to produce the ordered set of keys for the domain of the chart.
ordering
produces the key, and quicksort.by
sorts the keys.
This doesn’t provide complete control over the ordering of keys, so if you want to sort by some metric that is not in the reduced key/value pairs, or if you want to do a reverse alphabetical sort, you have to jump through hoops. Those hoops are jumpable, but
- It seems odd that crossfilter chose to restrict the API; usually sorting algorithms allow you to provide a
function(a,b)
that returns positive, negative, or zero. - Maybe it would be easier sometimes just to supply a function that takes the set of keys found in the data and produces an ordered set.
So, if this bothers you also, please leave a comment and we can expose the sorting algorithm. Cheers.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Say we have an array with the desired order, and we want to put the found keys in that order. You can produce an inverse-array mapping from strings to integers that does that.
Here is a workaround for sorting by an array of levels in an R factor.
Most of this discussion is about replacing
crossfilter.quicksort.by
with built-in sort, which has already been done.I opened #1658 to track the idea of exposing the predicate, so I’m closing this.