static void createSorted ( int a [ ] , int n ) {
  Vector < Integer > b = new Vector < > ( ) ;
  for ( int j = 0 ;
  j < n ;
  j ++ ) {
    if ( b . isEmpty ( ) ) b . add ( a [ j ] ) ;
    else {
      int start = 0 , end = b . size ( ) - 1 ;
      int pos = 0 ;
      while ( start <= end ) {
        int mid = start + ( end - start ) / 2 ;
        if ( b . get ( mid ) == a [ j ] ) {
          b . add ( ( Math . max ( 0 , mid + 1 ) ) , a [ j ] ) ;
          break ;
        }
        else if ( b . get ( mid ) > a [ j ] ) pos = end = mid - 1 ;
        else pos = start = mid + 1 ;
        if ( start > end ) {
          pos = start ;
          b . add ( Math . max ( 0 , pos ) , a [ j ] ) ;
          break ;
        }
      }
    }
  }
  for ( int i = 0 ;
  i < n ;
  i ++ ) System . out . print ( b . get ( i ) + " " ) ;
}

static void createSorted ( int a [ ] , int n ) { Vector < Integer > b = new Vector < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( b . isEmpty ( ) ) b . add ( a [ j ] ) ; else { int start = 0 , end = b . size ( ) - 1 ; int pos = 0 ; while ( start <= end ) { int mid = start + ( end - start ) / 2 ; if ( b . get ( mid ) == a [ j ] ) { b . add ( ( Math . max ( 0 , mid + 1 ) ) , a [ j ] ) ; break ; } else if ( b . get ( mid ) > a [ j ] ) pos = end = mid - 1 ; else pos = start = mid + 1 ; if ( start > end ) { pos = start ; b . add ( Math . max ( 0 , pos ) , a [ j ] ) ; break ; } } } } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( b . get ( i ) + " ▁ " ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (binary_expression left: (identifier) right: (decimal_integer_literal))))) (array_access array: (identifier) index: (identifier))))) (break_statement)) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (array_access array: (identifier) index: (identifier)))) consequence: (expression_statement (assignment_expression left: (identifier) right: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) alternative: (expression_statement (assignment_expression left: (identifier) right: (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal) (identifier))) (array_access array: (identifier) index: (identifier))))) (break_statement))))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (string_literal))))))))