# Path: raccoon/utils.py
# def assert_frame_equal(left, right, data_function=None, data_args=None):
#     """
#     For unit testing equality of two DataFrames.
# 
#     :param left: first DataFrame
#     :param right: second DataFrame
#     :param data_function: if provided will use this function to assert compare the df.data
#     :param data_args: arguments to pass to the data_function
#     :return: nothing
#     """
#     if data_function:
#         data_args = {} if not data_args else data_args
#         data_function(left.data, right.data, **data_args)
#     else:
#         assert left.data == right.data
#     assert left.index == right.index
#     assert left.columns == right.columns
#     assert left.index_name == right.index_name
#     assert left.sort == right.sort
#     assert left.dropin == right.dropin


import pytest
import raccoon as rc
from raccoon.utils import assert_frame_equal

    df.sort_columns('a')
    assert isinstance(df.index, list)
    assert_frame_equal(df, rc.DataFrame({'a': [1, 2, 3], 'b': ['c', 'a', 'b']}, columns=['a', 'b'], index=[8, 10, 9]))

    df.sort_columns('b')
    assert_frame_equal(df, rc.DataFrame({'a': [2, 3, 1], 'b': ['a', 'b', 'c']}, columns=['a', 'b'], index=[10, 9, 8]))

    df.sort_columns('b', reverse=True)
    assert_frame_equal(df, rc.DataFrame({'a': [1, 3, 2], 'b': ['c', 'b', 'a']}, columns=['a', 'b'], index=[8, 9, 10]))


def test_sort_column_w_key():
    df = rc.DataFrame({'a': [1, 2, 3, 4], 'b': ['a', 'b', 'c', 'd']}, columns=['a', 'b'], index=[8, 9, 10, 11])

    # No key, reverse
    df.sort_columns('a', key=None, reverse=True)
    assert_frame_equal(df, rc.DataFrame({'a': [4, 3, 2, 1], 'b': ['d', 'c', 'b', 'a']}, columns=['a', 'b'],
                                        index=[11, 10, 9, 8]))

    # a key function that turns evens into a odds into a negative number
    def even_to_neg(i):
        return i * -1 if i % 2 == 0 else i

    df.sort_columns('a', key=even_to_neg)
    assert_frame_equal(df, rc.DataFrame({'a': [4, 2, 1, 3], 'b': ['d', 'b', 'a', 'c']}, columns=['a', 'b'],
                                        index=[11, 9, 8, 10]))

    # with key and reverse
    df.sort_columns('a', key=even_to_neg, reverse=True)

# Path: raccoon/utils.py
# def assert_frame_equal(left, right, data_function=None, data_args=None):
#     """
#     For unit testing equality of two DataFrames.
# 
#     :param left: first DataFrame
#     :param right: second DataFrame
#     :param data_function: if provided will use this function to assert compare the df.data
#     :param data_args: arguments to pass to the data_function
#     :return: nothing
#     """
#     if data_function:
#         data_args = {} if not data_args else data_args
#         data_function(left.data, right.data, **data_args)
#     else:
#         assert left.data == right.data
#     assert left.index == right.index
#     assert left.columns == right.columns
#     assert left.index_name == right.index_name
#     assert left.sort == right.sort
#     assert left.dropin == right.dropin


# Path: tests/test_dataframe/test_sort.py
import pytest
import raccoon as rc
from raccoon.utils import assert_frame_equal


    df.sort_columns('a')
    assert isinstance(df.index, list)
    assert_frame_equal(df, rc.DataFrame({'a': [1, 2, 3], 'b': ['c', 'a', 'b']}, columns=['a', 'b'], index=[8, 10, 9]))

    df.sort_columns('b')
    assert_frame_equal(df, rc.DataFrame({'a': [2, 3, 1], 'b': ['a', 'b', 'c']}, columns=['a', 'b'], index=[10, 9, 8]))

    df.sort_columns('b', reverse=True)
    assert_frame_equal(df, rc.DataFrame({'a': [1, 3, 2], 'b': ['c', 'b', 'a']}, columns=['a', 'b'], index=[8, 9, 10]))


def test_sort_column_w_key():
    df = rc.DataFrame({'a': [1, 2, 3, 4], 'b': ['a', 'b', 'c', 'd']}, columns=['a', 'b'], index=[8, 9, 10, 11])

    # No key, reverse
    df.sort_columns('a', key=None, reverse=True)
    assert_frame_equal(df, rc.DataFrame({'a': [4, 3, 2, 1], 'b': ['d', 'c', 'b', 'a']}, columns=['a', 'b'],
                                        index=[11, 10, 9, 8]))

    # a key function that turns evens into a odds into a negative number
    def even_to_neg(i):
        return i * -1 if i % 2 == 0 else i

    df.sort_columns('a', key=even_to_neg)
    assert_frame_equal(df, rc.DataFrame({'a': [4, 2, 1, 3], 'b': ['d', 'b', 'a', 'c']}, columns=['a', 'b'],
                                        index=[11, 9, 8, 10]))

    # with key and reverse
    df.sort_columns('a', key=even_to_neg, reverse=True)

    assert_frame_equal(df, rc.DataFrame({'a': [3, 1, 2, 4], 'b': ['c', 'a', 'b', 'd']}, columns=['a', 'b'],