Closed sebastian-de closed 4 years ago
You did not explain why this needs to be done server-side. Sorting is a way of displaying, and displaying is within the client's responsibility. Do you have a reason why MPD should do this and not the client?
quoting https://github.com/jcorporation/myMPD/issues/256#issuecomment-622071468
Client side sorting is slow and error prone. I think you should open an issue for MPD.
I don't know if this is true or not. However other protocol commands that query the db like find
or search
already provide a server side way for sorting the results.
The result of lsinfo
currently gets sorted too, but the sorting defaults to the album tag. It would be nice to make this configurable either similar to the protocol commands mentioned above, or a configuration option.
If this is implemented in MPD, all clients could benefit from this and don't have to implement sorting by themselves.
But if this is something that's not wanted server side at all I'm fine.
Extending the protocol by a sort and a window option would be ideal for clients. It should be faster if the server sorts and transfers only the wanted range of the result to the client. Especially if the list is long as described by @sebastian-de.
If client sorts: myMPD (server process) gets the whole unsorted list from MPD, sorts the list in memory and puts the requested range from the sorted list to the client.
If server sorts: myMPD can transfer the requested range directly to client.
If the output of lsinfo is already sorted as sebastian-de wrotes than we sort one result unnecessarily a second time.
However other protocol commands that query the db like
find
orsearch
already provide a server side way for sorting the results.
Because those commands have a window
parameter which makes only sense if you have a well-defined ordering.
lsinfo
(which this request is about) doesn't have this. That's why @jcorporation's argument can't be applied.
I first opened a similar issue for the MPD client myMPD, but the maintainer suggested to open an issue here (myMPD issue).
Feature request
It would be nice to have a configuration option to sort MPD directory listings by filename. Ideally the folders would be listed first.
To be more specific: when I browse a directory using a MPD-client, I'd like it to be sorted like the output of
tree -L 1 <directory>
Example
Output of
tree -L 1 <directory>
MPD API command
lsinfo
of that same directory returns:What I tried so far
I don't know if modifying the simple db plugin is the right approach to do that, or if it would be better to do this via db_selection_print.
Motivation I organize my music collection in a directory structure with many sub-directories, which can contain a lot of single files that don't belong to an album. When listening to music I usually browse these directories with a file manager and pick the songs I'd like to play. When the directories aren't sorted by filename, it takes much longer for me to find the music I'd like to hear.