code: def test_sort_execution(setup):
      # only 1 chunk when axis = -1
      raw = np.random.rand(100, 10)
      x = tensor(raw, chunk_size=20)
  
      sx = sort(x)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      # 1-d chunk
      raw = np.random.rand(100)
      x = tensor(raw, chunk_size=20)
  
      sx = sort(x)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      # test force need_align=True
      sx = sort(x)
      sx.op._need_align = True
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      # test psrs_kinds
      sx = sort(x, psrs_kinds=[None, None, "quicksort"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      # structured dtype
      raw = np.empty(100, dtype=[("id", np.int32), ("size", np.int64)])
      raw["id"] = np.random.randint(1000, size=100, dtype=np.int32)
      raw["size"] = np.random.randint(1000, size=100, dtype=np.int64)
      x = tensor(raw, chunk_size=10)
  
      sx = sort(x, order=["size", "id"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(
          res, np.sort(raw, order=["size", "id"])
      )
  
      # test psrs_kinds with structured dtype
      sx = sort(
          x, order=["size", "id"], psrs_kinds=[None, None, "quicksort"]
      )
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(
          res, np.sort(raw, order=["size", "id"])
      )
  
      # test flatten case
      raw = np.random.rand(10, 10)
      x = tensor(raw, chunk_size=(5, 10))
  
      sx = sort(x, axis=None)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, axis=None))
  
      # test multi-dimension
      raw = np.random.rand(10, 100)
      x = tensor(raw, chunk_size=(5, 40))
  
      sx = sort(x, psrs_kinds=["quicksort"] * 3)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      sx = sort(x, psrs_kinds=[None, None, "quicksort"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      raw = np.random.rand(10, 99)
      x = tensor(raw, chunk_size=(5, 20))
  
      sx = sort(x)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      # test 3-d
      raw = np.random.rand(20, 25, 28)
      x = tensor(raw, chunk_size=(10, 15, 14))
  
      sx = sort(x)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      sx = sort(x, psrs_kinds=[None, None, "quicksort"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      sx = sort(x, axis=0)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, axis=0))
  
      sx = sort(x, axis=0, psrs_kinds=[None, None, "quicksort"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, axis=0))
  
      sx = sort(x, axis=1)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, axis=1))
  
      sx = sort(x, axis=1, psrs_kinds=[None, None, "quicksort"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, axis=1))
  
      # test multi-dimension with structured type
      raw = np.empty(
          (10, 100), dtype=[("id", np.int32), ("size", np.int64)]
      )
      raw["id"] = np.random.randint(
          1000, size=(10, 100), dtype=np.int32
      )
      raw["size"] = np.random.randint(
          1000, size=(10, 100), dtype=np.int64
      )
      x = tensor(raw, chunk_size=(7, 30))
  
      sx = sort(x)
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw))
  
      sx = sort(x, order=["size", "id"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(
          res, np.sort(raw, order=["size", "id"])
      )
  
      sx = sort(x, order=["size"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, order=["size"]))
  
      sx = sort(x, axis=0, order=["size", "id"])
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(
          res, np.sort(raw, axis=0, order=["size", "id"])
      )
  
      sx = sort(
          x,
          axis=0,
          order=["size", "id"],
          psrs_kinds=[None, None, "quicksort"],
      )
  
      res = sx.execute().fetch()
      np.testing.assert_array_equal(
          res, np.sort(raw, axis=0, order=["size", "id"])
      )
  
      # test inplace sort
      raw = np.random.rand(10, 12)
      a = tensor(raw, chunk_size=(5, 4))
      a.sort(axis=1)
  
      res = a.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw, axis=1))
  
      a.sort(axis=0)
  
      res = a.execute().fetch()
      np.testing.assert_array_equal(
          res, np.sort(np.sort(raw, axis=1), axis=0)
      )
  
      # test with empty chunk
      raw = np.random.rand(20, 10)
      raw[:, :8] = 1
      a = tensor(raw, chunk_size=5)
      filtered = a[a < 1]
      filtered.sort()
  
      res = filtered.execute().fetch()
      np.testing.assert_array_equal(res, np.sort(raw[raw < 1]))
  
imports: import numpy
  import scipy.sparse
  import pandas
  import pytest
  from ....None import dataframe
  from ....None import tensor
  from ....None import execute, fetch
  from ....tests.core import require_cupy
  from ...datasource import tensor, ones, zeros, arange
  from ..None import copyto, transpose, moveaxis, broadcast_to, broadcast_arrays, where, expand_dims, rollaxis, atleast_1d, atleast_2d, atleast_3d, argwhere, array_split, split, hsplit, vsplit, dsplit, roll, squeeze, diff, ediff1d, flip, flipud, fliplr, repeat, tile, isin, searchsorted, unique, sort, argsort, partition, argpartition, topk, argtopk, trapz, shape, to_gpu, to_cpu, swapaxes
label_desc: Use image node_id 32 for calling a global function with example usage: test_sort_execution(setup) without return types