var arr=[
{far:123.45,address:"金粮路"},
{far:3685.45,address:"北京路"},
{far:2.8,address:"人民公园"},
];

//根據距離遠近排序,越近在前面,升序
arr.sort(function (a, b) {
	if (a.far < b.far) {
		return -1;
	} else if (a.far == b.far) {
		return 0;
	} else {
		return 1;
	}
});

 


本文转载:CSDN博客