In Apache Druid, the topN metric spec specifies how topN values should be sorted.
The metric field can also be given as a JSON object. The grammar for dimension values sorted by numeric value is shown below:
The following metricSpec uses lexicographic sorting.
Sort dimension values in inverted order, i.e inverts the order of the delegate metric spec. It can be used to sort the values in ascending order.