How to sort elements in array as per time parameter?

 


The time values in array can be sorted as strings. Below is the source code for same:

array.sort((a, b) => a.time.localeCompare(b.time));
console.log(array);

 


Related #tags:     #node.js     #array     #sorting     #javascript    

Related questions




Looking for change? Click below to prepare for technical interview.


Technical Interview Questions