static Rule [ ] getOrderedRules ( final Rule [ ] rules ) { final Comparator < Rule > c = Comparator . comparing ( Rule :: getSize ) . reversed ( ) . thenComparing ( Rule :: getPattern ) ; final Rule [ ] result = Arrays . copyOf ( rules , rules . length ) ; parallelSort ( result , c ) ; return result ; }
Sort by size and alphabet so the first match can be returned immediately