按照数组中的对象属性进行排序

按照数组中的对象属性进行比较排序


**方法一: **

var arry = [{value:6,url:'xxx.html'},{value:3,url:'aaa.html'},{value:9,url:'bbb.html'}]
         function compare(property) { //按照数组中的对象属性进行排序
            return function (a, b) {
              var value1 = a[property];
              var value2 = b[property];
              return value1 - value2;
            }
          }

         arry.sort(compare('value'))

方法二:
没时间写了,我要去健身房了

原文地址:https://www.cnblogs.com/niluiquhz/p/10145234.html