UI: minor changes to preset sorting
- Only sort by the preset name (not it's directory). - Remove redundant string conversion. - Only call lower() once on the input. - Don't assign the lambda to a variable for single use.
This commit is contained in:
parent
511ff8b6b4
commit
663b0bb04c
|
@ -921,10 +921,11 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
|
|||
(filter_path(f)))
|
||||
])
|
||||
|
||||
# Python does not have a natural sort function
|
||||
natural_sort = lambda s: [int(t) if t.isdigit() else t.lower()
|
||||
for t in re.split('(\d+)', (str)(s))]
|
||||
files.sort(key=natural_sort)
|
||||
# Perform a "natural sort", so 20 comes after 3 (for example).
|
||||
files.sort(
|
||||
key=lambda file_path:
|
||||
tuple(int(t) if t.isdigit() else t for t in re.split("(\d+)", file_path[0].lower())),
|
||||
)
|
||||
|
||||
col = layout.column(align=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue