Skip to content

Add reverse sort order option - #1018

Merged
nift4 merged 6 commits into
FoedusProgramme:betafrom
manum45:beta
Sep 2, 2026
Merged

Add reverse sort order option#1018
nift4 merged 6 commits into
FoedusProgramme:betafrom
manum45:beta

Conversation

@manum45

@manum45 manum45 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Adds option to reverse the order type.
This solves #584
I kept the defaults of whether ascending or descending is used for each sort mode because I think it is helpful, and added a checkbox that causes the inverse of the default to be used (as opposed to adding an ascending <> descending toggle).

Also fixed some bugs in the sorting options.

Note: I made these changes with the help of an LLM, but I checked all of them and adapted where I saw fit.

@manum45 manum45 changed the title Add reverse order option Add reverse sort order option Sep 1, 2026

@nift4 nift4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, just another of these million things you never get around to. I left some comments


override fun sort(type: Sorter.Type) {
sortType.value = type
songAdapter.sort(type)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the song list's sort setting when changing the folder sort setting?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought both should be changed with the same button. I missed that there's a separate button for the song list. Will undo this change.

else types
res = res + Type.NaturalOrder + Type.NaturalOrderDescending
if (res.contains(Type.ByDiscAndTrack))
res = res + Type.ByDiscAndTrackDescending

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why special case here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right that's now redundant with the calculation below. will remove

}
val currentSort = adapter.sortType.value
val activeEntry = buttonMap.entries.find { it.value == currentSort || Sorter.Type.inverse(it.value) == currentSort }
val defaultSort = activeEntry?.value ?: Sorter.Type.None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you move this assingment below the null-check, you can get rid of the ?: None which is never used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaned this up a little

if (!menuItem.isChecked) {
adapter.sort(buttonMap[menuItem.itemId]!!)
val baseType = buttonMap[menuItem.itemId]!!
val targetType = if (reverseItem.isChecked) Sorter.Type.inverse(baseType) ?: baseType else baseType

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, wouldn't it be better UX to reset "reverse order" to false when user chooses a different sort type?

Perhaps saving a per-sort option cache to disk, so that following UX is achieved (example of main song list):

  1. User starts with sort option "Name", not reversed -> A-Z
  2. User enables reverse mode for Z-A order
  3. User selects Modified date sort option instead, because user didn't use this option before, reverse is automatically turned off
  4. Later, User selects name again, and the reverse state is restored, Z-A order is loaded automatically

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this would be the best behavior. But for now I'd like to keep the logic simple, especially since I don't have any experience with the preferences system.
I will implement the reset of the reverse order toggle if sorting type is changed.
Would that be fine for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, merging, I'll do the preference part later. Thanks for the PR! :)

@manum45
manum45 requested a review from nift4 September 2, 2026 21:26
@nift4
nift4 merged commit e8d3717 into FoedusProgramme:beta Sep 2, 2026
@manum45

manum45 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks :) should the issue be closed or do you want to keep it open for the preferences?

@nift4

nift4 commented Sep 3, 2026

Copy link
Copy Markdown
Member

Oh yeah I kinda expected it to auto-close, thanks for the reminder

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.

2 participants