`

Comparator 对list按照某个属性进行排序

 
阅读更多

List<Node> list =new ArrayList<Node>();
Collections.sort(kdAndKnList, new LofComparator());
class LofComparator implements Comparator<Node> {
		public int compare(Node A, Node B) {
			return A.getLof() - B.getLof() < 0 ? -1 : 1;
		}
	}
 从小到大进行排序
分享到:
评论
Global site tag (gtag.js) - Google Analytics