code: def _sort_result(self, result: cudf.DataFrame) -> cudf.DataFrame:
      # Pandas sorts on the key columns in the
      # same order as given in 'on'. If the indices are used as
      # keys, the index will be sorted. If one index is specified,
      # the key columns on the other side will be used to sort.
      # In pandas-compatible mode, tie-breaking for multiple equal
      # sort keys is to produce output in input dataframe order.
      # This is taken care of by using a stable sort here, and (in
      # pandas-compat mode) reordering the gather maps before
      # producing the input result.
      by: List[Any] = []
      if self._using_left_index and self._using_right_index:
          by.extend(result._index._data.columns)
      if not self._using_left_index:
          by.extend([result._data[col.name] for col in self._left_keys])
      if not self._using_right_index:
          by.extend(
              [result._data[col.name] for col in self._right_keys]
          )
      if by:
          keep_index = self._using_left_index or self._using_right_index
          if keep_index:
              to_sort = [*result._index._columns, *result._columns]
              index_names = result._index.names
          else:
              to_sort = [*result._columns]
              index_names = None
          result_columns = libcudf.sort.sort_by_key(
              to_sort,
              by,
              [True] * len(by),
              ["last"] * len(by),
              stable=True,
          )
          result = result._from_columns_like_self(
              result_columns, result._column_names, index_names
          )
      return result
  
file_path: cudf/python/cudf/cudf/core/join/join.py
imports: from __future__ import annotations
  import itertools
  import warnings
  from typing import Any, ClassVar, List, Optional
  import cudf
  from cudf import _lib
  from cudf._lib.types import size_type_dtype
  from cudf.core.copy_types import GatherMap
  from cudf.core.join._join_helpers import _coerce_to_tuple, _ColumnIndexer, _IndexIndexer, _match_join_keys
label_desc: Use image node_id 5 for calling the Merge obj's underlying member method code with example usage: obj._sort_result(result) and returns: result