sort for data table via query
Hi,
Current default sort for text data table charts is a little un-intuitive (at least for me). All other charts appear to respect the sort stage in the aggregation pipeline. The data table chart has a different mechanism where the user has to explicitly click on the header to define the default sort. This is counter intuitive if there is already a sort stage in the aggregation pipeline that can be interpreted as the default sort.
I think it might make things more clear if either:
a) Default sort ALWAYS in the sort stage of the aggregation
b) Flag a problem when someone is using the sort in the aggregation since it won't be considered.
There may be a good reason as to why this functions in this specific way and it IS documented (I should really read more carefully :) ). Apologies if this is nonsense in this case.
We’ve reworked how we do sorting, and the sort for all chart types (including tables) now happens within the aggregation pipeline.
-
AdminTom (Admin, MongoDB) commented
Hi Artur. The order that the documents are returned from the query (using an explicit $sort or by virtue of any indexes used) should not impact any chart. Most charts have the option to sort by category name or value, ascending or descending, on the encoding card in the main category channel. Tables are a little different because you can have multiple sort orders; these are defined by clicking the column headers in the preview.
Can you give an example of where you think the $sort in the aggregation is influencing the chart rendering?