question: public int compare ( String s1 , String s2 ) { final Matcher match1 = MATCH_ID_PATTERN . matcher ( s1 ) ; final Matcher match2 = MATCH_ID_PATTERN . matcher ( s2 ) ; final boolean match1matches = match1 . matches ( ) ; final boolean match2matches = match2 . matches ( ) ; if ( match1matches ^ match2matches ) { return ( match1matches ) ? 1 : - 1 ; } else if ( match1matches && match2matches ) { int signature1 = Integer . parseInt ( match1 . group ( 1 ) ) ; int signature2 = Integer . parseInt ( match2 . group ( 1 ) ) ; int comparison = ( signature1 < signature2 ) ? - 1 : ( signature1 > signature2 ) ? 1 : 0 ; if ( comparison == 0 ) { int start1 = Integer . parseInt ( match1 . group ( 2 ) ) ; int start2 = Integer . parseInt ( match2 . group ( 2 ) ) ; comparison = ( start1 < start2 ) ? - 1 : ( start1 > start2 ) ? 1 : 0 ; } if ( comparison == 0 ) { int end1 = Integer . parseInt ( match1 . group ( 3 ) ) ; int end2 = Integer . parseInt ( match2 . group ( 3 ) ) ; comparison = ( end1 < end2 ) ? - 1 : ( end1 > end2 ) ? 1 : 0 ; } return comparison ; } else { int seqLength1 = s1 . length ( ) , n2 = s2 . length ( ) ; for ( int i1 = 0 , i2 = 0 ; i1 < seqLength1 && i2 < n2 ; i1 ++ , i2 ++ ) { char c1 = s1 . charAt ( i1 ) ; char c2 = s2 . charAt ( i2 ) ; if ( c1 != c2 ) { c1 = Character . toUpperCase ( c1 ) ; c2 = Character . toUpperCase ( c2 ) ; if ( c1 != c2 ) { c1 = Character . toLowerCase ( c1 ) ; c2 = Character . toLowerCase ( c2 ) ; if ( c1 != c2 ) { return c1 - c2 ; } } } } return seqLength1 - n2 ; } }
target:  Sorts on the following: <p/> 1. The integer used to uniquely identify the signature 2. earliest start position 3. earliest stop position