var result = document.getElementById("result"); var test10Elements = [7, 6, 5, 4, 3, 2, 1, 0, 8, 9]; var test11Elements = [7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8]; var compareFn = function (x, y) { return x > y; }; test10Elements.sort(compareFn); test11Elements.sort(compareFn);
执行结果: