19 、集合元素排序
1 /** 2 * 对scoreDocs 进行排序 3 * @param scoreDocs 4 * @return 5 */ 6 public static ScoreDoc[] sort(ScoreDoc[] scoreDocs){ 7 Arrays.sort(scoreDocs, new Comparator<ScoreDoc>() { 8 @Override 9 public int compare(ScoreDoc scoreDoc1, ScoreDoc scoreDoc2) { 10 return scoreDoc1.doc-scoreDoc2.doc; 11 } 12 }); 13 return scoreDocs; 14 }
//获取字段列名和字段类型 List<TransformRuleInfo> list= inputConfigInfo.getList(); //按照index进行排序 Collections.sort(list, new Comparator<TransformRuleInfo>() { @Override public int compare(TransformRuleInfo o1, TransformRuleInfo o2) { return o1.getIndex() - o2.getIndex(); } })
本文来自博客园,作者:life_start,转载请注明原文链接:https://www.cnblogs.com/yangh2016/p/5872059.html