想要对表单数组进行排序 ["01:00 am","06:00 pm" ,"12:00 pm","03:00 am","12:00 am"]
请建议。
var times = ['01:00 am', '06:00 pm', '12:00 pm', '03:00 am', '12:00 am'];
times.sort(function (a, b) {
return new Date('1970/01/01 ' + a) - new Date('1970/01/01 ' + b);
});
console.log(times);
看看 Underscore.js SortBy 怎么样? http://underscorejs.org/#sortBy