示例代码如下/***定义一个比较器*@parampropertyName*@paramsortType*@returns{function(...[*]=)}*/functioncompare(propertyName,sortType){returnfunction(object1,object2){varvalue1=object1[propertyName];varvalue2=object2[propertyName];if(sortType==='asc'){if(value2>value1){return-1;}elseif(value2<value1){return1;}else