diff options
author | Seth Morton <seth.m.morton@gmail.com> | 2023-02-27 00:40:15 -0800 |
---|---|---|
committer | Seth Morton <seth.m.morton@gmail.com> | 2023-02-27 00:40:15 -0800 |
commit | 99a252e445a75a115431ee8fa18f487375ca9d20 (patch) | |
tree | 150a471469b36a9b03b0012303aa9c91cae4aeb6 /natsort/ns_enum.py | |
parent | e778c1742fc94766b42110580809795605ca3c88 (diff) | |
parent | 92969665342450fb450904776a59bd8406dfe65a (diff) | |
download | natsort-99a252e445a75a115431ee8fa18f487375ca9d20.tar.gz |
Merge branch 'introduce-consistent-sorting-for-corner-cases'
Diffstat (limited to 'natsort/ns_enum.py')
-rw-r--r-- | natsort/ns_enum.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/natsort/ns_enum.py b/natsort/ns_enum.py index c147909..02f970f 100644 --- a/natsort/ns_enum.py +++ b/natsort/ns_enum.py @@ -114,6 +114,14 @@ class ns(enum.IntEnum): # noqa: N801 treat these as +Infinity and place them after all the other numbers. By default, an NaN be treated as -Infinity and be placed first. Note that this ``None`` is treated like NaN internally. + PRESORT, PS + Sort the input as strings before sorting with the `nasort` + algorithm. This can help eliminate inconsistent sorting in cases + where two different strings represent the same number. For example, + "a1" and "a01" both are internally represented as ("a", "1), so + without `PRESORT` the order of these two values would depend on + the order they appeared in the input (because Python's `sorted` + is a stable sorting algorithm). Notes ----- @@ -143,6 +151,7 @@ class ns(enum.IntEnum): # noqa: N801 NANLAST = NL = 1 << next(_counter) COMPATIBILITYNORMALIZE = CN = 1 << next(_counter) NUMAFTER = NA = 1 << next(_counter) + PRESORT = PS = 1 << next(_counter) # Following were previously options but are now defaults. DEFAULT = 0 |