def METHOD_NAME(self, X):
    if _is_pandas_df(X):
        ordered_df = X.sort_index(ascending=self.ascending)
    elif _is_spark_df(X):
        index_cols = get_index_names(X)  # type:ignore
        ordered_df = X.orderBy(index_cols, ascending=self.ascending)
    else:
        raise ValueError(
            "Only Pandas or Spark dataframe are supported as inputs. Please check that pyspark is installed if you see this error for a Spark dataframe."
        )
    ordered_df = forward_metadata(X, ordered_df)
    return ordered_df