dictknife icon indicating copy to clipboard operation
dictknife copied to clipboard

feat: new module, dictknife.sort -- for flexible sorting in diff check?

Open podhmo opened this issue 7 years ago • 1 comments

podhmo avatar Nov 14 '18 10:11 podhmo

This pull request introduces a new flexible sorting mechanism in dictknife and provides comprehensive tests to ensure correctness and robustness. The main changes include the implementation of the sorting logic in dictknife/sort.py and the addition of unit tests in dictknife/tests/test_sort.py.

Sorting Mechanism Implementation:

  • Flexible Sorting Functionality: Added the sort_flexibly function, which can sort various data structures (lists, dictionaries, etc.) based on a consistent and hierarchical UID system. This includes helper classes (_Atom, _Collection, _Dict) to wrap and sort elements according to their type and value. (dictknife/sort.py, dictknife/sort.pyR1-R137)

Testing Enhancements:

  • Unit Tests for Wrapping Logic: Added a WrapTests class to test the _wrap function, ensuring that elements are correctly wrapped and sorted based on their UID. (dictknife/tests/test_sort.py, dictknife/tests/test_sort.pyR1-R121)
  • Unit Tests for Flexible Sorting: Added a Tests class to validate the sort_flexibly function across a variety of input scenarios, including primitive types, nested structures, and missing values. (dictknife/tests/test_sort.py, dictknife/tests/test_sort.pyR1-R121)

podhmo avatar Jul 05 '25 01:07 podhmo