nodes: 0, module; 1, function_definition; 2, function_name:sort_values; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, identifier:return_indexer; 11, False; 12, identifier:ascending; 13, True; 14, comment:"""
          Return sorted copy of Index.
          """; 15, identifier:return_indexer; 16, block; 17, else_clause; 18, expression_statement; 19, if_statement; 20, expression_statement; 21, return_statement; 22, block; 23, assignment; 24, not_operator; 25, block; 26, assignment; 27, expression_list; 28, expression_statement; 29, expression_statement; 30, expression_statement; 31, if_statement; 32, expression_statement; 33, if_statement; 34, return_statement; 35, identifier:_as; 36, call; 37, identifier:ascending; 38, expression_statement; 39, identifier:sorted_index; 40, call; 41, identifier:sorted_index; 42, identifier:_as; 43, assignment; 44, assignment; 45, assignment; 46, boolean_operator; 47, block; 48, assignment; 49, not_operator; 50, block; 51, call; 52, attribute; 53, argument_list; 54, assignment; 55, attribute; 56, argument_list; 57, identifier:sorted_values; 58, call; 59, identifier:attribs; 60, call; 61, identifier:freq; 62, subscript; 63, comparison_operator:freq is not None; 64, not_operator; 65, if_statement; 66, subscript; 67, identifier:freq; 68, identifier:ascending; 69, expression_statement; 70, attribute; 71, argument_list; 72, identifier:self; 73, identifier:argsort; 74, identifier:_as; 75, subscript; 76, identifier:self; 77, identifier:take; 78, identifier:_as; 79, attribute; 80, argument_list; 81, attribute; 82, argument_list; 83, identifier:attribs; 84, string; 85, identifier:freq; 86, None; 87, call; 88, boolean_operator; 89, block; 90, elif_clause; 91, identifier:attribs; 92, string; 93, assignment; 94, identifier:self; 95, identifier:_simple_new; 96, identifier:sorted_values; 97, dictionary_splat; 98, identifier:_as; 99, slice; 100, identifier:np; 101, identifier:sort; 102, attribute; 103, identifier:self; 104, identifier:_get_attributes_dict; 105, string_content:freq; 106, identifier:is_period_dtype; 107, argument_list; 108, comparison_operator:freq.n > 0; 109, not_operator; 110, expression_statement; 111, boolean_operator; 112, block; 113, string_content:freq; 114, identifier:sorted_values; 115, subscript; 116, identifier:attribs; 117, unary_operator; 118, identifier:self; 119, identifier:_ndarray_values; 120, identifier:self; 121, attribute; 122, integer:0; 123, identifier:ascending; 124, assignment; 125, comparison_operator:freq.n < 0; 126, identifier:ascending; 127, expression_statement; 128, identifier:sorted_values; 129, slice; 130, integer:1; 131, identifier:freq; 132, identifier:n; 133, identifier:freq; 134, binary_operator:freq * -1; 135, attribute; 136, integer:0; 137, assignment; 138, unary_operator; 139, identifier:freq; 140, unary_operator; 141, identifier:freq; 142, identifier:n; 143, identifier:freq; 144, binary_operator:freq * -1; 145, integer:1; 146, integer:1; 147, identifier:freq; 148, unary_operator; 149, integer:1
code: def sort_values(self, return_indexer=False, ascending=True):
          """
          Return sorted copy of Index.
          """
          if return_indexer:
              _as = self.argsort()
              if not ascending:
                  _as = _as[::-1]
              sorted_index = self.take(_as)
              return sorted_index, _as
          else:
              sorted_values = np.sort(self._ndarray_values)
              attribs = self._get_attributes_dict()
              freq = attribs['freq']
  
              if freq is not None and not is_period_dtype(self):
                  if freq.n > 0 and not ascending:
                      freq = freq * -1
                  elif freq.n < 0 and ascending:
                      freq = freq * -1
              attribs['freq'] = freq
  
              if not ascending:
                  sorted_values = sorted_values[::-1]
  
              return self._simple_new(sorted_values, **attribs)