js 数组排序要注意的问题,返回的值最好为 -1, 0, 1之间的值
var test10Elements = [7, 6, 5, 4, 3, 2, 1, 0, 8, 9]; var comparefn = function (x, y) { return x - y; }; test10Elements.sort(comparefn); var comparefn2 = function (x, y) { return x > y; }; test10Elements.sort(comparefn2);
![](http://images0.cnblogs.com/i/505976/201406/241919437366283.jpg)