Sort DataTable:
// sort by column 0, descending data.sort({column: 0, desc: true});
or use a sorted DataView:
var view = new google.visualization.DataView(data); view.setRows(data.getSortedRows({column: 0, desc: true})); table.draw(view, options);
Sorting a DataTable changes the actual order of the data and affects other tables / tables using the DataTable. This can be expensive in terms of CPU usage if the DataTable contains a large number of rows. Using a DataView saves the data in the original DataTable (due to a small increase in memory usage) and is relatively cheap in terms of CPU time, but if your DataTable is not huge or you don't have other diagrams that rely on it, you are probably safe just sorting the base DataTable
source share