let fechas = ['13/02/2018 02:55:00 PM', '24/08/2017 09:40:00 AM', '01/04/2011 10:55:00 AM'];
Array.prototype._w3skulls = function(){
let res = new Array();
for (let i = 0; i < this.length; i++) {
let f = this[i][0].split('/');
let aux = f[2];
f[2] = f[0];
f[0] = aux;
this[i][0] = f[0].concat('-' + f[1] + '-' + f[2]);
let h = this[i][1].split(':');
if(this[i][2] == 'PM'){
h[0] = parseInt(h[0]) + 12;
}
this[i][1] = h[0] + ':' + h[1] + ':' + h[2];
res[i] = this[i][0] + ' '+ this[i][1];
}
return res;
};
function sortDates(fechas){
let f_aux = fechas.map(function(elem, index, array) {
return elem.split(' ');
});
let res = f_aux._w3skulls();
let w3 = new Array();
res.forEach(function(item, index){
w3[index] = new Date(item);
});
w3.sort();
for(let i = 0; i < w3.length; i++){
let dia = ''; let mes = ''; let hora =''; let min = ''; let seg ='';
let am = 'am';
if(w3[i].getDate() < 10){
dia = '0' + w3[i].getDate();
}else{
dia = w3[i].getDate();
}
if((w3[i].getMonth() + 1) < 10){
mes = '0' + (w3[i].getMonth() + 1);
}else{
mes = (w3[i].getMonth() + 1);
}
if((w3[i].getHours() - 12) > 10){
hora = '0' + w3[i].getHours();
am = 'pm';
}else{
hora = w3[i].getHours();
}
if(w3[i].getMinutes() < 10){
min = '0' + w3[i].getMinutes();
}else{
min =w3[i].getMinutes();
}
if(w3[i].getSeconds() < 10){
seg = '0' + w3[i].getSeconds();
}else{
seg = w3[i].getSeconds();
}
w3[i] = dia + '/' + mes + '/' + w3[i].getFullYear() + ' ' + hora + ':' + min + ':' + seg + ' ' + am.toUpperCase();
}
return w3;
}
console.log(sortDates(fechas));