code: def _reorder_by_uniques(
      uniques: npt.NDArray[np.int64], labels: npt.NDArray[np.intp]
  ) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.intp]]:
      """
      Parameters
      ----------
      uniques : np.ndarray[np.int64]
      labels : np.ndarray[np.intp]
  
      Returns
      -------
      np.ndarray[np.int64]
      np.ndarray[np.intp]
      """
      # sorter is index where elements ought to go
      sorter = uniques.argsort()
  
      # reverse_indexer is where elements came from
      reverse_indexer = np.empty(len(sorter), dtype=np.intp)
      reverse_indexer.put(sorter, np.arange(len(sorter)))
  
      mask = labels < 0
  
      # move labels to right locations (ie, unsort ascending labels)
      labels = reverse_indexer.take(labels)
      np.putmask(labels, mask, -1)
  
      # sort observed ids
      uniques = uniques.take(sorter)
  
      return uniques, labels
  
imports: from __future__ import annotations
  from collections import defaultdict
  from typing import TYPE_CHECKING, Callable, DefaultDict, cast
  import numpy
  from pandas._libs import algos, hashtable, lib
  from pandas._libs.hashtable import unique_label_indices
  from pandas.core.dtypes.common import ensure_int64, ensure_platform_int
  from pandas.core.dtypes.generic import ABCMultiIndex, ABCRangeIndex
  from pandas.core.dtypes.missing import isna
  from pandas.core.construction import extract_array
label_desc: Use image node_id 17 for calling a global function with example usage: _reorder_by_uniques(uniques, labels) and returns: uniques,  labels