code: def sort(a, axis=-1, kind="quicksort", order=None):
      """
  
      Parameters
      ----------
      a: TensorVariable
          Tensor to be sorted
      axis: TensorVariable
          Axis along which to sort. If None, the array is flattened before
          sorting.
      kind: {'quicksort', 'mergesort', 'heapsort'}, optional
          Sorting algorithm. Default is 'quicksort'.
      order: list, optional
          When `a` is a structured array, this argument specifies which
          fields to compare first, second, and so on. This list does not
          need to include all of the fields.
  
      Returns
      -------
      array
          A sorted copy of an array.
  
      """
      if axis is None:
          a = a.flatten()
          axis = 0
      return SortOp(kind, order)(a, axis)
  
imports: import numpy
  from pytensor.gradient import grad_undefined
  from pytensor.graph.basic import Apply, Constant
  from pytensor.graph.op import Op
  from pytensor.misc.safe_asarray import _asarray
  from pytensor.tensor.basic import arange, as_tensor_variable, flatten, switch
  from pytensor.tensor.math import eq, ge, mul
  from pytensor.tensor.shape import shape
  from pytensor.tensor.subtensor import set_subtensor
  from pytensor.tensor.type import TensorType, integer_dtypes
label_desc: Use image node_id 3 for calling a global function with example usage: sort(a, axis, kind, order) and returns: SortOp