sort the input array
for ( let i = 0 ; i < n ; i ++ ) { let s = arr [ i ] ; let len = s . length ; if ( count [ len - 1 ] == 0 ) { sortedArr [ len - 1 ] = s ; count [ len - 1 ] = 1 ; } else if ( sortedArr [ len - 1 ] == s ) {