Skip to content

natural sort: exclude extension when comparing filenames

Currently natural sort compares the entire filenames (basename.extension) when sorting. This causes eg. "a 2.txt" to appear before "a.txt" when sorted by ascending. This is unintuitive since people prioritize basenames more than file extensions.

Instead, change natural sort to compare by basename only and fallback to comparing extensions if basenames were equal. This change causes "a.txt" to appear before "a 2.txt" and matches how other platforms such as GNOME and Windows behave.

BUG: 416025, BUG: 470538, BUG: 421869, BUG: 312027

Edited by Eren Karakas

Merge request reports

Loading