var files = [{
"FileName": "520120427043622011.jpg",
"UpdateTimeStamp": "Jun 10, 2013 8:31:23 AM"
},{
"FileName": "Kung_Fu_Fingers.jpg",
"UpdateTimeStamp": "Jun 5, 2013 6:51:12 AM"
},{
"FileName": "google_logo1.jpg",
"UpdateTimeStamp": "Jun 10, 2013 8:31:23 AM"
}];
files.sort(function(a, b){
var d1 = new Date(a.UpdateTimeStamp);
var d2 = new Date(b.UpdateTimeStamp);
return d1-d2; // d2-d1 for descending order
});
EDIT:
For array of timestamps
var updateTimeStamps = ["Aug 10, 2013 8:31:23 AM","Jun 5, 2013 6:51:12 AM" ,"May 10, 2013 8:31:23 AM"];
updateTimeStamps.sort(function(a, b){
var d1 = new Date(a);
var d2 = new Date(b);
return d1-d2; // d2-d1 for descending order
});
console.log(updateTimeStamps);
EDIT 2:
For keeping two arrays and sorting
var imgs = ["img1", "img2", "img3"];
var times = ["Jul 10, 2013 8:31:23 AM","Jan 5, 2013 6:51:12 AM" ,"Feb 10, 2013 8:31:23 AM"];
var sorting = [];
times.sort(function(a, b){
var d1 = new Date(a);
var d2 = new Date(b);
var d = d1-d2; // d2-d1 for descending order
sorting.push(d);
return d;
});
imgs.sort(function(a, b){
return sorting.shift();
});
console.log(times);
console.log(imgs);