I\'m trying to sort an Array of dates from latest to oldest, and unfortunately list.sort (by default) only sorts the first number. My array looks like this:
var
You would have to pass a sorting function to the sort method and define a date parsing function that creates an ordered representation of the date like so:
var MyArray = ["13 Jun", "09 Jun", "25 Aug", "30 Jun", "13 Aug"];
MyArray.sort(function (a, b) {
a = parseDate(a);
b = parseDate(b);
if (a < b) {
return 1;
} else if (a > b) {
return -1;
} else {
return 0;
}
});