首页 > Web开发 > 详细

js 数组排序要注意的问题,返回的值最好为 -1, 0, 1之间的值

时间:2014-06-25 13:38:19      阅读:311      评论:0      收藏:0      [点我收藏+]

 

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);

 

bubuko.com,布布扣bubuko.com,布布扣

http://w3help.org/zh-cn/causes/SJ9013

js 数组排序要注意的问题,返回的值最好为 -1, 0, 1之间的值,布布扣,bubuko.com

js 数组排序要注意的问题,返回的值最好为 -1, 0, 1之间的值

原文:http://www.cnblogs.com/qiangspecial/p/3806741.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!