JSFiddle - React, Tailwind, and code Playground

by Korah Babu Varghese

JavaScript

var data = {'August.2018': {Flights: 274834},
'December.2019': {Flights: 222036},
'February.2019': {Flights: 299376},
'January.2019': {Flights: 399559},
'July.2019': {Flights: 187985},
'June.2019': {Flights: 143985},
'March.2019': {Flights: 242277},
'November.2019': {Flights: 194460},
'October.2019': {Flights: 1943880},
'September.2019': {Flights: 122304}};
// object which holds the order value of the month
var monthNames = [
  "January",
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December"
];

// sort the data array
data.sort(function(a, b) {
  // sort based on the value in the monthNames object
  return monthNames[a[0]] - monthNames[b[0]];
});

document.write('<pre>' + JSON.stringify(data, 0, 3) + '</pre>')