The solution in the answer by Kevbotanswer by Kevbot is elegant, but its application is limited to ES6 browsers with an implementation of date.parse() that conforms to the specific date format used by the OP.
Instead of adding a library such as moment.js just to avoid the date.parse() dependency, a tailored solution that will work in any JavaScript environment (including old browsers) can be made with just a few lines of code:
var dates = [
{'August 17th 2016': [75]},
{'August 1st 2016': [5]},
{'August 28th 2016': [5]}
];
dates.sort(function(a, b){
var i, j;
for(i in a); //get datestring a
for(j in b); //get datestring b;
return MMMDDYYYYtoSortableNumber(i) -
MMMDDYYYYtoSortableNumber(j);
});
console.log(dates);
// MMMDDYYYYtoSortableNumber() converts datestrings
// such as "April 5th 1969" to 19690405.
// Month name to digit approach adapted from
// https://gist.github.com/atk/1053863
function MMMDDYYYYtoSortableNumber(datestring) {
var mdy = datestring.match(/\w(\w\w)\D+(\d+)\D+(\d+)/);
return mdy[3] * 10000 +
' anebarprayunulugepctovec'.search(mdy[1]) * 50 +
mdy[2] * 1;
}
Please note that it might be safer to represent the datestrings as object values rather than object keys. They will then be easier to extract safely (and faster to access). E.g.
{label: 'August 17th 2016', data: [75]},