Format and sort data for Highcharts