Sort by an artificial field

Hello,
I have a very simple chart without aggregations: Category and Amount and I would like to sort the categories alphabetically. I can't use CAML to sort by Category, because Category it's not a SharePoint field, but an artificial field built by a very complex algorithm in the DataSource/Advanced /handlers.requestInit compartment.

I tried in the Dashboard / Advanced compartment the code below, but it doesn't work.

var handlers = {};
handlers.preRender = function(config, logger) {
var data = config.series[0].data;

data.sort(function(a, b) {
return a.Category - b.Category;
});
logger.debug('Configuration: ', config);
return true;
}

Help me, please. Thank you

Hello @Cumatale,

You can try to re-order data in the finish handler in Data source -> Advanced tab.

Also please see Configure aggregation and sorting article for more examples.