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写个冒泡排序就行。没什么难度啊。