diff options
Diffstat (limited to 'natsort/utils.py')
-rw-r--r-- | natsort/utils.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/natsort/utils.py b/natsort/utils.py index b86225e..2a3745f 100644 --- a/natsort/utils.py +++ b/natsort/utils.py @@ -420,7 +420,17 @@ def parse_number_or_none_factory( val: Any, _nan_replace: float = nan_replace, _sep: StrOrBytes = sep ) -> BasicTuple: """Given a number, place it in a tuple with a leading null string.""" - return _sep, (_nan_replace if val != val or val is None else val) + # Add a trailing string numbers equaling _nan_replace. This will make + # the ordering between None NaN, and the NaN replacement value... + # None comes first, then NaN, then the replacement value. + if val is None: + return _sep, _nan_replace, "1" + elif val != val: + return _sep, _nan_replace, "2" + elif val == _nan_replace: + return _sep, _nan_replace, "3" + else: + return _sep, val # Return the function, possibly wrapping in tuple if PATH is selected. if alg & ns.PATH and alg & ns.UNGROUPLETTERS and alg & ns.LOCALEALPHA: |