Q:

How to short Timing Array Data with From and To keys

This is JSON of random timing data in 24 hours format
var timeArray = [
    {from: "17:00:00", to: "18:00:00"},
    {from: "09:45:00", to: "14:30:00"},
    {from: "20:00:00", to: "23:45:00"}];

expected output is sorted like
var timeArray = [
    {from: "09:45:00", to: "14:30:00"},
    {from: "17:00:00", to: "18:00:00"},
    {from: "20:00:00", to: "23:45:00"}];

is there any logic or function to achieve this in javascript or angularjs?

A:

var timeArray = [
  { from: "09:45:00", to: "14:30:00" },
  { from: "17:00:00", to: "18:00:00" },
  { from: "20:00:00", to: "23:45:00" }
];
console.log(timeArray.sort((a, b) => b.from > a.from ? -1 : 1))

