【发布时间】:2018-06-23 16:07:34
【问题描述】:
我们有一个月份数字数组:
const months = [1,2,3,4,5,6,7,8,9,10,11,12];
我们如何从当前月份开始对这个数组进行排序?例如
const currentMonth = 9; // September
months.sort((current, next) => {
// ... sorting algorithm here
});
console.log(months); // Prints Array [9,8,7,6,5,4,3,2,1,12,11,10]
【问题讨论】:
标签: javascript arrays node.js ecmascript-6 functional-programming