1. 程式人生 > >排序演算法,從大到小

排序演算法,從大到小

1、得到list中最大的那個值

public OppoSiteInfo getMaxMatch(List<OppoSiteInfo> list){
		float maxScore = 0;
		int index = 0;
		for(int i=0;i<list.size();i++){
			if(list.get(i).getMatchScore() > maxScore){
				maxScore = list.get(i).getMatchScore();
				index = i;
			}
		}
		OppoSiteInfo oppoSiteInfo = list.get(index);
		list.remove(index);
		return oppoSiteInfo;
	}

 2、得到的templist為排序後的list

List<OppoSiteInfo> tempList = new ArrayList<OppoSiteInfo>();
		for(int k=0;k<matchList.size();k++){
			tempList.add(getMaxMatch(matchList));
		}