JSFiddle - React, Tailwind, and code Playground

by Yomi Eluwande

JavaScript

var times = ['01 am', '06 pm', '12 pm', '03 am', '12 am'];

times.sort(function (a, b) {
  return new Date('1970/01/01 ' + a) - new Date('1970/01/01 ' + b);
});

console.log(times);