I have dynamic date and time being generated and I need to sort them in descending order using JavaScript.
my data is in the below format.
var array= ["25-Jul-2017 12:46:39 pm","25-Jul-2017 12:52:23 pm","25-Jul-2017 12:47:18 pm"];
Anyone help would be appreciated.
array.sort((a,b) => new Date(b).getTime() - new Date(a).getTime())-? We can use ternary operator witha > b ? 1 : a < b : -1 : 0