Skip to content

Conversation

SuniRein
Copy link

@SuniRein SuniRein commented Aug 18, 2025

Which issue does this PR resolve?

Resolves #3064

What's changed?

You can combine different sorting methods in yazi.toml, like

sort-by = ["extension", "natural"]

A single string is interpreted as a single-element array. For example,

sort-by = "extension"

is treated the same as

sort-by = ["extension"]

for compatibility.

If two files are equivalent in all specified methods, it'll fallback to alphabetical, which is the same as before.

And you can also set sorting methods by keymaps by specifying multiple methods:

prepend_keymaps = [
  { on = [ ",", "e" ], run = [ "sort extension natural" ], desc = "Sort by extension in natural order" }
]

Further discussion

Currently sort-reverse is applied to all sorting methods globally, rather than allowing certain sorting methods to be reversed individually as some other file managers do.

However, the current configuration format could not extend this feature gracefully. Moreover, I personally do not have a strong need for it. So I did not implement it in this PR.

@SuniRein SuniRein force-pushed the feat/combine-sorting-methods branch from 777e226 to 7a76cc4 Compare August 18, 2025 12:00
@SuniRein SuniRein changed the title Feat/combine sorting methods feat: combine sorting methods Aug 18, 2025
@sxyazi
Copy link
Owner

sxyazi commented Aug 18, 2025

Currently sort-reverse is applied to all sorting methods globally, rather than allowing certain sorting methods to be reversed individually as some other file managers do.

This is actually a pretty good question, thank you for bringing it up! Let me give it some more thought on the future extension concern

`sort-by = ["extension", "natural"]` will first sort by extension then
sort naturally, and `sort-by = "extension"` will still work as before.
@SuniRein SuniRein force-pushed the feat/combine-sorting-methods branch from 7a76cc4 to d0219cf Compare September 10, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combine different sorting methods
2 participants