let t_data = sortByKey(pz_data.data, "yield_per_mu");
//array:当前数组
//key:数组中需要比较大小的值
export const sortByKey = (array: any, key: any) => {
return array.sort(function (a: any, b: any) {
var x = b[key];
var y = a[key];
return x < y ? -1 : x > y ? 1 : 0;
});
};
标签:数组,对比,key,vue3,array,data,any
From: https://www.cnblogs.com/JaneLifeBlog/p/17869212.html