nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:x; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, import_from_statement; 12, expression_statement; 13, return_statement; 14, identifier:axis; 15, unary_operator; 16, identifier:reverse; 17, False; 18, identifier:with_index; 19, False; 20, identifier:only_index; 21, False; 22, comment:"""Sorts the elements of `x` along a given `axis` in ascending order
      by value. A negative `axis` counts from the last dimension of `x`,
      so the default of -1 sorts along the last dimension. If `reverse`
      is True, then the elements are soreted in descending order.
  
      If `with_index` is True, result is a tuple ``(sorted, indices)``
      or only ``indices`` if `only_index` is True. Setting `only_index`
      to True implies that `with_index` is also True.
  
      .. code-block:: python
  
          import numpy as np
          import nnabla as nn
          import nnabla.functions as F
  
          nn.set_auto_forward(True)
          x = nn.Variable.from_numpy_array(np.random.rand(2, 3, 4))
  
          sorted = F.sort(x)
          assert np.allclose(sorted.d, np.sort(x.d))
  
          sorted, indices = F.sort(x, with_index=True)
          assert np.allclose(sorted.d, np.sort(x.d))
          assert np.all(indices.d == np.argsort(x.d))
  
          indices = F.sort(x, only_index=True)
          assert np.all(indices.d == np.argsort(x.d))
  
      Args:
          x(~nnabla.Variable): N-D array
          axis(int): Axis along which to sort.
          reverse(bool): Sort in descending order.
          with_index(bool): Return sorted values and index.
          only_index(bool): Return only the sort index.
  
      Returns: :obj:`~nnabla.Variable` `sorted` or :obj:`~nnabla.Variable` `indices` or (:obj:`~nnabla.Variable` `sorted`, :obj:`~nnabla.Variable` `indices`)
  
      """; 23, relative_import; 24, aliased_import; 25, assignment; 26, call; 27, integer:1; 28, import_prefix; 29, dotted_name; 30, dotted_name; 31, identifier:sort_base; 32, identifier:n_outputs; 33, conditional_expression:2 if with_index and not only_index else 1; 34, identifier:sort_base; 35, argument_list; 36, identifier:function_bases; 37, identifier:sort; 38, integer:2; 39, boolean_operator; 40, integer:1; 41, identifier:x; 42, identifier:axis; 43, identifier:reverse; 44, identifier:with_index; 45, identifier:only_index; 46, identifier:n_outputs; 47, identifier:with_index; 48, not_operator; 49, identifier:only_index
code: def sort(x, axis=-1, reverse=False, with_index=False, only_index=False):
      """Sorts the elements of `x` along a given `axis` in ascending order
      by value. A negative `axis` counts from the last dimension of `x`,
      so the default of -1 sorts along the last dimension. If `reverse`
      is True, then the elements are soreted in descending order.
  
      If `with_index` is True, result is a tuple ``(sorted, indices)``
      or only ``indices`` if `only_index` is True. Setting `only_index`
      to True implies that `with_index` is also True.
  
      .. code-block:: python
  
          import numpy as np
          import nnabla as nn
          import nnabla.functions as F
  
          nn.set_auto_forward(True)
          x = nn.Variable.from_numpy_array(np.random.rand(2, 3, 4))
  
          sorted = F.sort(x)
          assert np.allclose(sorted.d, np.sort(x.d))
  
          sorted, indices = F.sort(x, with_index=True)
          assert np.allclose(sorted.d, np.sort(x.d))
          assert np.all(indices.d == np.argsort(x.d))
  
          indices = F.sort(x, only_index=True)
          assert np.all(indices.d == np.argsort(x.d))
  
      Args:
          x(~nnabla.Variable): N-D array
          axis(int): Axis along which to sort.
          reverse(bool): Sort in descending order.
          with_index(bool): Return sorted values and index.
          only_index(bool): Return only the sort index.
  
      Returns: :obj:`~nnabla.Variable` `sorted` or :obj:`~nnabla.Variable` `indices` or (:obj:`~nnabla.Variable` `sorted`, :obj:`~nnabla.Variable` `indices`)
  
      """
      from .function_bases import sort as sort_base
      n_outputs = 2 if with_index and not only_index else 1
      return sort_base(x, axis, reverse, with_index, only_index, n_outputs)