private static HyphenationPattern[] sortPatterns(HyphenationPattern[] patternArray) {

    Comparator<HyphenationPattern> comparator = new Comparator<HyphenationPattern>() {

      @Override
      public int compare(HyphenationPattern p1, HyphenationPattern p2) {

        return (p2.getWordPart().length() - p1.getWordPart().length());
      }
    };
    Arrays.sort(patternArray, comparator);
    return patternArray;
  }
private static HyphenationPattern [ ] sortPatterns ( HyphenationPattern [ ] patternArray ) { Comparator < HyphenationPattern > comparator = new Comparator < HyphenationPattern > ( ) { @ Override public int compare ( HyphenationPattern p1 , HyphenationPattern p2 ) { return ( p2 . getWordPart ( ) . length ( ) - p1 . getWordPart ( ) . length ( ) ) ; } } ; Arrays . sort ( patternArray , comparator ) ; return patternArray ; }
This method sorts the given {@link HyphenationPattern patterns} according to the {@link String#length() length} of
their {@link HyphenationPattern#getWordPart() word-part}.

@param patternArray are the unsorted {@link HyphenationPattern patterns}.
@return the sorted {@link HyphenationPattern patterns}.