//商家类Store 按距离进行排序
public class ComparatorStore implements Comparator<Store> { @Override public int compare(Store lhs, Store rhs) { return lhs.getDistance() - rhs.getDistance(); } }
//////////....................
//调用排序
List<Store> stores = new ArrayList<Store>();
stores.add(new Store("name",152));//名字,距离
stores.add(new Store("name",155));//名字,距离
stores.add(new Store("name",154));//名字,距离
stores.add(new Store("name",172));//名字,距离
stores.add(new Store("name",1511));//名字,距离
Collections.sort(AppManager.result, new ComparatorStore());
原文:http://www.cnblogs.com/sleepend/p/3679078.html