code: def _ascending_sort(values, axis, return_argsort=False):
      """Sorts values in ascending order.
  
      Args:
        values: Tensor of numeric values.
        axis: Index of the axis which values should be sorted along.
        return_argsort: If False, return the sorted values. If True, return the
          indices that would sort the values.
  
      Returns:
        The sorted values.
      """
      # TODO(b/190410105): replace with a proper sort kernel.
      # If values are integers, we need special handling.
      dtype = values.dtype
      if dtype.is_unsigned:
          # Subtract values from dtype.max to reverse sort order.
          offset = dtype.max
          values_or_indices = _descending_sort(
              offset - values, axis, return_argsort
          )
          return (
              values_or_indices
              if return_argsort
              else offset - values_or_indices
          )
  
      elif dtype.is_integer:
          # Negate and subtract 1 to map dtype.min to dtype.max.  Technically this
          # will result in signed-integer-overflow UB for dtype.min, though
          # practically should produce correct results on all systems.
          #
          # Casting to unsigned would be better, but uint* subtraction is not
          # supported on all devices.
          #
          # Although more complex and slightly slower than descend+reverse, this
          # approach preserves sort stability.
          values_or_indices = _descending_sort(
              -values - 1, axis, return_argsort
          )
          return (
              values_or_indices
              if return_argsort
              else -values_or_indices - 1
          )
  
      else:
          # Otherwise, negate the values and use descending sort.
          values_or_indices = _descending_sort(
              -values, axis, return_argsort
          )
          # If not argsort, negate the values again.
          return (
              values_or_indices
              if return_argsort
              else -values_or_indices
          )
  
file_path: tensorflow-upstream/tensorflow/python/ops/sort_ops.py
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.util import dispatch
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 5 for calling a global function with example usage: _ascending_sort(values, axis, return_argsort) and returns: unknown, unknown, unknown