order by year and month javascript code example
Example: sort date according to months in javascript
var allMonths = ['Jan','Feb','Mar', 'Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var month = [ "Apr","May","Jun","Oct","Nov","Dec","Jul","Aug","Sep"];
month.sort(function(a,b){
return allMonths.indexOf(a) - allMonths.indexOf(b);
});
// returns ["Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]