question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow specifying ordering algorithm, e.g. descending?

See original GitHub issue

Filing 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

  1. 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.
  2. 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gordonwoodhullcommented, Jun 11, 2016

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.

0reactions
gordonwoodhullcommented, Feb 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Different ways to sort an array in descending order in C# ...
Arranging the array's elements from largest to smallest is termed as sorting the array in descending order. Examples: Input : array = {5,...
Read more >
The Python Sort List Array Method – Ascending and ...
To specify that reverse is True, so the list has to be sorted in descending (reverse) order.
Read more >
ORDER BY in MySQL: DESC & ASC Query with EXAMPLE
The MySQL DESC keyword specifies that the sorting is to be in descending order. [LIMIT] is optional but can be used to limit...
Read more >
Sorting algorithm - Wikipedia
The most frequently used orders are numerical order and lexicographical order, and either ascending or descending. Efficient sorting is important for optimizing ...
Read more >
Enumerable.OrderByDescending Method (System.Linq)
Sorts the elements of a sequence in descending order by using a specified comparer. ... For an example of this method, see OrderByDescending<TSource ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found