/**
* 将列表进行排序
*
* @param infoList
*/
public void sortList(List<Info> infoList) {
if (infoList != null && infoList.size() > 0) {
for (int i = 1; i < infoList.size(); i++) {
// 按面积比较
if (infoList.get(i - 1).getArea() < infoList.get(i)
.getArea()) {
Info tempInfo = infoList.get(i);
int j = 0;
for (j = i - 1; j >= 0
&& infoList.get(j).getArea() < tempInfo
.getArea(); j--) {
infoList.set(j + 1, infoList.get(j));
}
infoList.set(j + 1, tempInfo);
} else if (infoList.get(i - 1).getArea() == infoList.get(
i).getArea()) {
// 面积相等,按x比较
Info tempInfo = infoList.get(i);
int j = 0;
for (j = i - 1; j >= 0; j--) {
if (infoList.get(j).getX() > tempInfo.getX()) {
// X升序
infoList.set(j + 1, infoList.get(j));
} else if (infoList.get(j).getX() == tempInfo.getX()) {
// y升序
for (j = i - 1; j >= 0
&& infoList.get(j).getY() > tempInfo
.getY(); j--) {
// y升序
infoList.set(j + 1, infoList.get(j));
}
} else {
break;
}
}
infoList.set(j + 1, tempInfo);
}
}
}
}