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, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, comment:# Validate the axis parameter; 14, expression_statement; 15, comment:# GH 5856/5853; 16, if_statement; 17, function_definition; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, expression_statement; 24, if_statement; 25, if_statement; 26, if_statement; 27, if_statement; 28, expression_statement; 29, if_statement; 30, identifier:axis; 31, integer:0; 32, identifier:ascending; 33, True; 34, identifier:inplace; 35, False; 36, identifier:kind; 37, string; 38, identifier:na_position; 39, string; 40, comment:"""
          Sort by the values.
  
          Sort a Series in ascending or descending order by some
          criterion.
  
          Parameters
          ----------
          axis : {0 or 'index'}, default 0
              Axis to direct sorting. The value 'index' is accepted for
              compatibility with DataFrame.sort_values.
          ascending : bool, default True
              If True, sort values in ascending order, otherwise descending.
          inplace : bool, default False
              If True, perform operation in-place.
          kind : {'quicksort', 'mergesort' or 'heapsort'}, default 'quicksort'
              Choice of sorting algorithm. See also :func:`numpy.sort` for more
              information. 'mergesort' is the only stable  algorithm.
          na_position : {'first' or 'last'}, default 'last'
              Argument 'first' puts NaNs at the beginning, 'last' puts NaNs at
              the end.
  
          Returns
          -------
          Series
              Series ordered by values.
  
          See Also
          --------
          Series.sort_index : Sort by the Series indices.
          DataFrame.sort_values : Sort DataFrame by the values along either axis.
          DataFrame.sort_index : Sort DataFrame by indices.
  
          Examples
          --------
          >>> s = pd.Series([np.nan, 1, 3, 10, 5])
          >>> s
          0     NaN
          1     1.0
          2     3.0
          3     10.0
          4     5.0
          dtype: float64
  
          Sort values ascending order (default behaviour)
  
          >>> s.sort_values(ascending=True)
          1     1.0
          2     3.0
          4     5.0
          3    10.0
          0     NaN
          dtype: float64
  
          Sort values descending order
  
          >>> s.sort_values(ascending=False)
          3    10.0
          4     5.0
          2     3.0
          1     1.0
          0     NaN
          dtype: float64
  
          Sort values inplace
  
          >>> s.sort_values(ascending=False, inplace=True)
          >>> s
          3    10.0
          4     5.0
          2     3.0
          1     1.0
          0     NaN
          dtype: float64
  
          Sort values putting NAs first
  
          >>> s.sort_values(na_position='first')
          0     NaN
          1     1.0
          2     3.0
          4     5.0
          3    10.0
          dtype: float64
  
          Sort a series of strings
  
          >>> s = pd.Series(['z', 'b', 'd', 'a', 'c'])
          >>> s
          0    z
          1    b
          2    d
          3    a
          4    c
          dtype: object
  
          >>> s.sort_values()
          3    a
          1    b
          4    c
          2    d
          0    z
          dtype: object
          """; 41, assignment; 42, call; 43, boolean_operator; 44, block; 45, function_name:_try_kind_sort; 46, parameters; 47, comment:# easier to ask forgiveness than permission; 48, block; 49, assignment; 50, assignment; 51, assignment; 52, assignment; 53, assignment; 54, assignment; 55, call; 56, block; 57, not_operator; 58, block; 59, not_operator; 60, block; 61, comparison_operator:na_position == 'last'; 62, block; 63, elif_clause; 64, else_clause; 65, assignment; 66, identifier:inplace; 67, block; 68, else_clause; 69, string_content:quicksort; 70, string_content:last; 71, identifier:inplace; 72, call; 73, attribute; 74, argument_list; 75, identifier:inplace; 76, attribute; 77, raise_statement; 78, identifier:arr; 79, try_statement; 80, identifier:arr; 81, attribute; 82, identifier:sortedIdx; 83, call; 84, identifier:bad; 85, call; 86, identifier:good; 87, unary_operator; 88, identifier:idx; 89, call; 90, identifier:argsorted; 91, call; 92, identifier:is_list_like; 93, argument_list; 94, if_statement; 95, expression_statement; 96, call; 97, raise_statement; 98, identifier:ascending; 99, expression_statement; 100, identifier:na_position; 101, string; 102, expression_statement; 103, expression_statement; 104, expression_statement; 105, comparison_operator:na_position == 'first'; 106, block; 107, block; 108, identifier:result; 109, call; 110, expression_statement; 111, block; 112, identifier:validate_bool_kwarg; 113, argument_list; 114, identifier:self; 115, identifier:_get_axis_number; 116, identifier:axis; 117, identifier:self; 118, identifier:_is_cached; 119, call; 120, comment:# if kind==mergesort, it can fail for object dtype; 121, block; 122, except_clause; 123, identifier:self; 124, identifier:_values; 125, attribute; 126, argument_list; 127, identifier:isna; 128, argument_list; 129, identifier:bad; 130, attribute; 131, argument_list; 132, identifier:_try_kind_sort; 133, argument_list; 134, identifier:ascending; 135, comparison_operator:len(ascending) != 1; 136, block; 137, assignment; 138, identifier:is_bool; 139, argument_list; 140, call; 141, assignment; 142, string_content:last; 143, assignment; 144, assignment; 145, assignment; 146, identifier:na_position; 147, string; 148, expression_statement; 149, expression_statement; 150, expression_statement; 151, raise_statement; 152, attribute; 153, argument_list; 154, call; 155, return_statement; 156, identifier:inplace; 157, string; 158, identifier:ValueError; 159, argument_list; 160, return_statement; 161, identifier:TypeError; 162, comment:# stable sort not available for object dtype; 163, comment:# uses the argsort default quicksort; 164, block; 165, identifier:np; 166, identifier:empty; 167, call; 168, keyword_argument; 169, identifier:arr; 170, identifier:ibase; 171, identifier:default_index; 172, call; 173, subscript; 174, call; 175, integer:1; 176, raise_statement; 177, identifier:ascending; 178, subscript; 179, identifier:ascending; 180, identifier:ValueError; 181, argument_list; 182, identifier:argsorted; 183, subscript; 184, identifier:n; 185, call; 186, subscript; 187, subscript; 188, subscript; 189, subscript; 190, string_content:first; 191, assignment; 192, assignment; 193, assignment; 194, call; 195, identifier:self; 196, identifier:_constructor; 197, subscript; 198, keyword_argument; 199, attribute; 200, argument_list; 201, call; 202, string_content:inplace; 203, concatenated_string; 204, call; 205, return_statement; 206, identifier:len; 207, argument_list; 208, identifier:dtype; 209, attribute; 210, identifier:len; 211, argument_list; 212, identifier:arr; 213, identifier:good; 214, identifier:len; 215, argument_list; 216, call; 217, identifier:ascending; 218, integer:0; 219, string; 220, identifier:argsorted; 221, slice; 222, attribute; 223, argument_list; 224, identifier:sortedIdx; 225, slice; 226, subscript; 227, identifier:argsorted; 228, identifier:sortedIdx; 229, slice; 230, identifier:idx; 231, identifier:bad; 232, identifier:n; 233, call; 234, subscript; 235, subscript; 236, subscript; 237, subscript; 238, identifier:ValueError; 239, argument_list; 240, identifier:arr; 241, identifier:sortedIdx; 242, identifier:index; 243, subscript; 244, identifier:self; 245, identifier:_update_inplace; 246, identifier:result; 247, attribute; 248, argument_list; 249, string:"This Series is a view of some other array, to "; 250, string:"sort in-place you must create a copy"; 251, attribute; 252, argument_list; 253, call; 254, identifier:self; 255, identifier:np; 256, identifier:int32; 257, identifier:self; 258, identifier:ascending; 259, identifier:ValueError; 260, argument_list; 261, string_content:ascending must be boolean; 262, unary_operator; 263, identifier:good; 264, identifier:sum; 265, identifier:n; 266, identifier:idx; 267, identifier:good; 268, identifier:n; 269, attribute; 270, argument_list; 271, identifier:sortedIdx; 272, slice; 273, subscript; 274, identifier:argsorted; 275, identifier:sortedIdx; 276, slice; 277, identifier:idx; 278, identifier:bad; 279, call; 280, attribute; 281, identifier:sortedIdx; 282, identifier:result; 283, identifier:__finalize__; 284, identifier:self; 285, identifier:arr; 286, identifier:argsort; 287, keyword_argument; 288, attribute; 289, argument_list; 290, binary_operator:'Length of ascending (%d) must be 1 '
                                   'for Series' % (len(ascending)); 291, integer:1; 292, identifier:bad; 293, identifier:sum; 294, identifier:n; 295, identifier:idx; 296, identifier:good; 297, identifier:n; 298, attribute; 299, argument_list; 300, identifier:self; 301, identifier:index; 302, identifier:kind; 303, identifier:kind; 304, identifier:arr; 305, identifier:argsort; 306, keyword_argument; 307, concatenated_string; 308, parenthesized_expression; 309, string; 310, identifier:format; 311, identifier:na_position; 312, identifier:kind; 313, string; 314, string; 315, string; 316, call; 317, string_content:invalid na_position: {!r}; 318, string_content:quicksort; 319, string_content:Length of ascending (%d) must be 1; 320, string_content:for Series; 321, identifier:len; 322, argument_list; 323, identifier:ascending
code: def sort_values(self, axis=0, ascending=True, inplace=False,
                      kind='quicksort', na_position='last'):
          """
          Sort by the values.
  
          Sort a Series in ascending or descending order by some
          criterion.
  
          Parameters
          ----------
          axis : {0 or 'index'}, default 0
              Axis to direct sorting. The value 'index' is accepted for
              compatibility with DataFrame.sort_values.
          ascending : bool, default True
              If True, sort values in ascending order, otherwise descending.
          inplace : bool, default False
              If True, perform operation in-place.
          kind : {'quicksort', 'mergesort' or 'heapsort'}, default 'quicksort'
              Choice of sorting algorithm. See also :func:`numpy.sort` for more
              information. 'mergesort' is the only stable  algorithm.
          na_position : {'first' or 'last'}, default 'last'
              Argument 'first' puts NaNs at the beginning, 'last' puts NaNs at
              the end.
  
          Returns
          -------
          Series
              Series ordered by values.
  
          See Also
          --------
          Series.sort_index : Sort by the Series indices.
          DataFrame.sort_values : Sort DataFrame by the values along either axis.
          DataFrame.sort_index : Sort DataFrame by indices.
  
          Examples
          --------
          >>> s = pd.Series([np.nan, 1, 3, 10, 5])
          >>> s
          0     NaN
          1     1.0
          2     3.0
          3     10.0
          4     5.0
          dtype: float64
  
          Sort values ascending order (default behaviour)
  
          >>> s.sort_values(ascending=True)
          1     1.0
          2     3.0
          4     5.0
          3    10.0
          0     NaN
          dtype: float64
  
          Sort values descending order
  
          >>> s.sort_values(ascending=False)
          3    10.0
          4     5.0
          2     3.0
          1     1.0
          0     NaN
          dtype: float64
  
          Sort values inplace
  
          >>> s.sort_values(ascending=False, inplace=True)
          >>> s
          3    10.0
          4     5.0
          2     3.0
          1     1.0
          0     NaN
          dtype: float64
  
          Sort values putting NAs first
  
          >>> s.sort_values(na_position='first')
          0     NaN
          1     1.0
          2     3.0
          4     5.0
          3    10.0
          dtype: float64
  
          Sort a series of strings
  
          >>> s = pd.Series(['z', 'b', 'd', 'a', 'c'])
          >>> s
          0    z
          1    b
          2    d
          3    a
          4    c
          dtype: object
  
          >>> s.sort_values()
          3    a
          1    b
          4    c
          2    d
          0    z
          dtype: object
          """
          inplace = validate_bool_kwarg(inplace, 'inplace')
          # Validate the axis parameter
          self._get_axis_number(axis)
  
          # GH 5856/5853
          if inplace and self._is_cached:
              raise ValueError("This Series is a view of some other array, to "
                               "sort in-place you must create a copy")
  
          def _try_kind_sort(arr):
              # easier to ask forgiveness than permission
              try:
                  # if kind==mergesort, it can fail for object dtype
                  return arr.argsort(kind=kind)
              except TypeError:
                  # stable sort not available for object dtype
                  # uses the argsort default quicksort
                  return arr.argsort(kind='quicksort')
  
          arr = self._values
          sortedIdx = np.empty(len(self), dtype=np.int32)
  
          bad = isna(arr)
  
          good = ~bad
          idx = ibase.default_index(len(self))
  
          argsorted = _try_kind_sort(arr[good])
  
          if is_list_like(ascending):
              if len(ascending) != 1:
                  raise ValueError('Length of ascending (%d) must be 1 '
                                   'for Series' % (len(ascending)))
              ascending = ascending[0]
  
          if not is_bool(ascending):
              raise ValueError('ascending must be boolean')
  
          if not ascending:
              argsorted = argsorted[::-1]
  
          if na_position == 'last':
              n = good.sum()
              sortedIdx[:n] = idx[good][argsorted]
              sortedIdx[n:] = idx[bad]
          elif na_position == 'first':
              n = bad.sum()
              sortedIdx[n:] = idx[good][argsorted]
              sortedIdx[:n] = idx[bad]
          else:
              raise ValueError('invalid na_position: {!r}'.format(na_position))
  
          result = self._constructor(arr[sortedIdx], index=self.index[sortedIdx])
  
          if inplace:
              self._update_inplace(result)
          else:
              return result.__finalize__(self)