从版号排序到手写Sort
给版本号排序 var versions = ['2.0.1', '1.1.0', '1.0.2', '2.0.0', '1.0.0', '3.0.10', '2.1.10', '2.0.0']; versions.sort((a, b) => { const alist = a.split('.'); const blist = b.split('.'); for (let i = 0; i < alist.length; i ++) { if (alist[i] > blist[i]) { return 1; } else if (alist[i] < blist[i]) { return -1; } else { continue; } } return 0; }) sort是...