Customize natsort using the ns enum and bitwise OR
mainYou can combine multiple sorting algorithms and modifiers using the bitwise OR operator (|) with the ns enum. The ns enum provides both long names (e.g., ns.LOCALE) and short forms (e.g., ns.L).
Available modifiers include:
ns.REAL/ns.R(Signed floats)ns.LOCALE/ns.L(Locale-aware)ns.IGNORECASE/ns.IC(Case-insensitive)
from natsort import natsorted, ns
a = ['Apple', 'apple15', 'Banana', 'apple14,689', 'banana']
# Combine multiple modifiers
natsorted(a, alg=ns.REAL | ns.LOCALE | ns.IGNORECASE)
# Using short forms
natsorted(a, alg=ns.R | ns.L | ns.IC)