자바 의 정렬

1036 단어 자바
자바 의 정렬 가능 한 패키지
import java.util.Collections;
        //  Collections    List     
        //    Comparator    
        Collections.sort(result, new Comparator() {
            @Override
            public int compare(Recorder o1, Recorder o2){
                 //  "coder"  , count     
                if(o1.getCount() != o2.getCount())
                    return o2.getCount() - o1.getCount();
                 //  index, index     
                else return o1.getIndex() - o2.getIndex();
            }
        });
        String sorted[] = new String[result.size()];
        for(int i=0;i

주의 하 다.
Collections.sort 는 병합 정렬 을 사용 합 니 다.
Collections.sort 의 compare 함 수 는 매우 열심히 써 야 합 니 다!

좋은 웹페이지 즐겨찾기