private < T extends URNIdentified > Stream < T > sortStreamLexicographically ( Stream < T > inputStream ) { Spliterator < T > spliterator = inputStream . spliterator ( ) ; if ( spliterator . hasCharacteristics ( Spliterator . SORTED ) && spliterator . getComparator ( ) . equals ( this . lexicographicalComparator ) ) { return StreamSupport . stream ( spliterator , false ) ; } return StreamSupport . stream ( spliterator , false ) . sorted ( this . lexicographicalComparator ) ; }
Sort input stream lexicographically . Noop if the input stream is already sorted .