parameters: (values, axis, direction, return_argsort)
return_statement: return _SORT_IMPL[direction](values, axis_static, return_argsort)
docstring: Internal sort/argsort implementation.
  
    Args:
      values: The input values.
      axis: The axis along which to sort.
      direction: 'ASCENDING' or 'DESCENDING'.
      return_argsort: Whether to return the argsort result.
  
    Returns:
      Either the sorted values, or the indices of the sorted values in the
          original tensor. See the `sort` and `argsort` docstrings.
  
    Raises:
      ValueError: If axis is not a constant scalar, or the direction is invalid.
docstring_summary: Internal sort/argsort implementation.
docstring_tokens: Internal sort / argsort implementation .
function: def _sort_or_argsort(values, axis, direction, return_argsort):
    """Internal sort/argsort implementation.
  
    Args:
      values: The input values.
      axis: The axis along which to sort.
      direction: 'ASCENDING' or 'DESCENDING'.
      return_argsort: Whether to return the argsort result.
  
    Returns:
      Either the sorted values, or the indices of the sorted values in the
          original tensor. See the `sort` and `argsort` docstrings.
  
    Raises:
      ValueError: If axis is not a constant scalar, or the direction is invalid.
    """
    if direction not in _SORT_IMPL:
      raise ValueError('%s should be one of %s' % (direction, ', '.join(
          sorted(_SORT_IMPL.keys()))))
    # Axis must be an integer, not a Tensor.
    axis = framework_ops.convert_to_tensor(axis, name='axis')
    axis_static = tensor_util.constant_value(axis)
    if axis.shape.ndims != 0 or axis_static is None:
      raise ValueError('axis must be a constant scalar')
    axis_static = int(axis_static)  # Avoids NumPy casting error
  
    values = framework_ops.convert_to_tensor(values, name='values')
  
    return _SORT_IMPL[direction](values, axis_static, return_argsort)
function_tokens: def _sort_or_argsort ( values , axis , direction , return_argsort ) : if direction not in _SORT_IMPL : raise ValueError ( '%s should be one of %s' % ( direction , ', ' . join ( sorted ( _SORT_IMPL . keys ( ) ) ) ) ) # Axis must be an integer, not a Tensor. axis = framework_ops . convert_to_tensor ( axis , name = 'axis' ) axis_static = tensor_util . constant_value ( axis ) if axis . shape . ndims != 0 or axis_static is None : raise ValueError ( 'axis must be a constant scalar' ) axis_static = int ( axis_static ) # Avoids NumPy casting error values = framework_ops . convert_to_tensor ( values , name = 'values' ) return _SORT_IMPL [ direction ] ( values , axis_static , return_argsort )