summaryrefslogtreecommitdiff
path: root/tests/test_os_sorted.py
diff options
context:
space:
mode:
authorSeth Morton <seth.m.morton@gmail.com>2023-02-27 00:22:59 -0800
committerSeth Morton <seth.m.morton@gmail.com>2023-02-27 00:34:55 -0800
commit50389e16d3aba5139890e14d57257320a9bc7e11 (patch)
treeae00d7e693c7534aa2cc61b044ceae8236e54edd /tests/test_os_sorted.py
parentcf2a55daf7e74d177c95149da623172b1b6d93ae (diff)
downloadnatsort-50389e16d3aba5139890e14d57257320a9bc7e11.tar.gz
Add presort to natsorted and friends
This will sort the collection as strings before sorting with the natsort algorithm. This ensures that strings that are different but represent the same numerical value get sorted independent of input order.
Diffstat (limited to 'tests/test_os_sorted.py')
-rw-r--r--tests/test_os_sorted.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_os_sorted.py b/tests/test_os_sorted.py
index f714437..c29c110 100644
--- a/tests/test_os_sorted.py
+++ b/tests/test_os_sorted.py
@@ -47,6 +47,13 @@ def test_os_sorted_key() -> None:
assert result == expected
+def test_os_sorted_can_presort() -> None:
+ given = ["a1", "a01"]
+ expected = ["a01", "a1"]
+ result = natsort.os_sorted(given, presort=True)
+ assert result == expected
+
+
# The following is a master list of things that might give trouble
# when sorting like the file explorer.
given_characters = [