static void twoWaySort ( Integer arr [ ] , int n ) {
  int l = 0 , r = n - 1 ;
  int k = 0 ;
  while ( l < r ) {
    while ( arr [ l ] % 2 != 0 ) {
      l ++ ;
      k ++ ;
    }
    while ( arr [ r ] % 2 == 0 && l < r ) r -- ;
    if ( l < r ) {
      int temp = arr [ l ] ;
      arr [ l ] = arr [ r ] ;
      arr [ r ] = temp ;
    }
  }
  Arrays . sort ( arr , 0 , k , Collections . reverseOrder ( ) ) ;
  Arrays . sort ( arr , k , n ) ;
}

static void twoWaySort ( Integer arr [ ] , int n ) { int l = 0 , r = n - 1 ; int k = 0 ; while ( l < r ) { while ( arr [ l ] % 2 != 0 ) { l ++ ; k ++ ; } while ( arr [ r ] % 2 == 0 && l < r ) r -- ; if ( l < r ) { int temp = arr [ l ] ; arr [ l ] = arr [ r ] ; arr [ r ] = temp ; } } Arrays . sort ( arr , 0 , k , Collections . reverseOrder ( ) ) ; Arrays . sort ( arr , k , n ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (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: (identifier) 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 (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (decimal_integer_literal))) body: (block (expression_statement (update_expression (identifier))) (expression_statement (update_expression (identifier))))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (identifier)))) body: (expression_statement (update_expression (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal) (identifier) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))))