发布网友
共2个回答
热心网友
var arr = [{x: 0, y: 2}, {x: 2, y: 2}, {x: 1, y: 1}];
arr.sort((a, b) => a.x < b.x);
console.log(arr)
热心网友
自己用FOR写个冒泡排序就行。没什么难度啊。