void sortLostFiles ( List < String > files ) { // TODO: We should first fix the files that lose more blocks Comparator < String > comp = new Comparator < String > ( ) { public int compare ( String p1 , String p2 ) { Codec c1 = null ; Codec c2 = null ; for ( Codec codec : Codec . getCodecs ( ) ) { if ( isParityFile ( p1 , codec ) ) { c1 = codec ; } else if ( isParityFile ( p2 , codec ) ) { c2 = codec ; } } if ( c1 == null && c2 == null ) { return 0 ; // both are source files } if ( c1 == null && c2 != null ) { return - 1 ; // only p1 is a source file } if ( c2 == null && c1 != null ) { return 1 ; // only p2 is a source file } return c2 . priority - c1 . priority ; // descending order } } ; Collections . sort ( files , comp ) ; }
Sorts source files ahead of parity files .