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);
![](https://i-blog.csdnimg.cn/blog_migrate/b9c8bcc53a1f42990c00234726d863f2.jpeg)
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);
转载于:https://www.cnblogs.com/qiangspecial/p/3806741.html