Added comparison method to sort the data arrays before building the chart