Sort so folders are grouped together

This commit is contained in:
Isaiah Odhner 2023-09-06 17:23:46 -04:00
parent 25a4b0826b
commit 2bbee95142

View File

@ -118,7 +118,7 @@ class GalleryApp(App[None]):
# Well, I can do it mostly, but for comparing "v1" and "v1.1", I need to consider the version number as a group. # Well, I can do it mostly, but for comparing "v1" and "v1.1", I need to consider the version number as a group.
# For two-number version strings, I could consider it as a float, but for three-number version strings, a tuple should work. # For two-number version strings, I could consider it as a float, but for three-number version strings, a tuple should work.
# I don't have any three-number version strings in the filenames of my ANSI art samples, but TODO: generalize this. # I don't have any three-number version strings in the filenames of my ANSI art samples, but TODO: generalize this.
matches_and_paths = [(re.findall(r"(\d*(?:\.\d+)?)(\D*)", path.name), path) for path in paths] matches_and_paths = [(re.findall(r"(\d*(?:\.\d+)?)(\D*)", str(path)), path) for path in paths]
sorted_parts_and_paths = sorted(matches_and_paths, key=lambda matches_and_path: [ sorted_parts_and_paths = sorted(matches_and_paths, key=lambda matches_and_path: [
[ [
# If ints or strings are conditionally omitted, it leads to int vs str comparison errors. # If ints or strings are conditionally omitted, it leads to int vs str comparison errors.