JS encapsulation sort method

排序方法

sortChange(property) {
    return function(a, b) {
        var value1 = a[property];
		var value2 = b[property];
		return value1 - value2;
	};
 }


调用排序方法

list.sort(this.sortChange("ReType"));

list为排序的数据

ReType为排序的字段,也就是按照哪个字段进行排序

Guess you like

Origin blog.csdn.net/qq_42753983/article/details/127281632