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();
            }
        })

 

posted @ 2016-09-14 14:08  life_start  阅读(129)  评论(0编辑  收藏  举报