自定义排序方式,通过array.sort
// 按助力值、绑定时间排序。return<0: a在前,return>0: a在后,return==0: 不变 list.sort(function (a, b) { var ref = 0 if (a.bind_at - b.bind_at < 0) { //a比b早创建 ref -= 1 } if (a.bind_at - b.bind_at > 0) { ref += 1 } if (a.value - b.value > 0) { //a助力值比b高 ref -= 10 } if (a.value - b.value < 0) { ref += 10 } return ref })
标签:sort,自定义,bind,JavaScript,value,排序,ref From: https://www.cnblogs.com/ximu1009/p/16897435.html