function sortEvents(events) { // return Object.keys(events) // .sort() // .reduce((sortedEvents, key) => { // sortedEvents[key] = events[key]; // return sortedEvents; // }, {}); const sortedEvents = {}; Object.keys(events) .sort() .forEach((key) => { sortedEvents[key] = events[key]; }); return sortedEvents; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter