Sort the ranges in ascending order
Arrays . sort ( arr , ( a , b ) -> { if ( a [ 0 ] . equals ( b [ 0 ] ) ) return Integer . compare ( a [ 1 ] , b [ 1 ] ) ; return Integer . compare ( a [ 0 ] , b [ 0 ] ) ; } ) ;