function up(x,y){//升序 return x[val.prop] - y[val.prop] } function down(x,y){//降序 return y[val.prop] - x[val.prop] }
arr.sort(up) arr.sort(down)code