-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve file sorting #43018
Improve file sorting #43018
Conversation
a52f827
to
c5b4bd6
Compare
This appears when I try to sort by type:
Also, is this intended that sorting doesn't affect directories? |
No this crash is not intended. Let me try something, I suppose there's a wrong pointer somewhere. |
That's not what I asked 🙃 |
Ah yes sorry. Maybe I could sort the directories too when the "Name descending" is chosen. But otherwise, yes, it is intended that directories are always before files. |
c5b4bd6
to
91491b9
Compare
I've updated the PR, could you try if it still crashes on your side ? |
Yeah that's what I meant. It just looks weird that no matter what you chose the directories don't change at all.
It's fixed. |
91491b9
to
d17b338
Compare
Alright, I updated the PR, the folder are also sorted too now. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is good functionality-wise. I didn't check the code thoroughly, but it looks ok too.
d17b338
to
be36cf8
Compare
for (int i = reversed ? p_dir->get_subdir_count() - 1 : 0; | ||
reversed ? i >= 0 : i < p_dir->get_subdir_count(); | ||
reversed ? i-- : i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO that might be more readable as two separate for loops in if
and else
branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely also easier to unroll/optimize for compilers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I see you have the same case further down on a bigger for
loop, where the duplication might not be wanted. Your call :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is the best solution I came up with for now.
I could have done something like storing the data in a list, like how it's done for files. But it was over-complicating things for little gain. It though duplicating the whole loop (the big one), removing everything to a function, only to be able to iterate over it in reverse was a little bit too much too.
So I went for this solution and kept things consistent for the too places it was used in. I agree it's not very readable, but I think the "reversed" variable name is at least obvious on what this does.
be36cf8
to
6f696a5
Compare
Thanks! |
Follow up of #42654.
Modifies the way the type sorting is done by also using the class icons in the comparison function. This specifically group similar resources together.
Also adds the possibility to sort according to the last modification date and in reserve order for each mode.