MPD icon indicating copy to clipboard operation
MPD copied to clipboard

Add sort paramter to `list`

Open jcorporation opened this issue 8 months ago • 9 comments

Feature request

#2255 implements the window parameter for list. To complete the implementation a sort parameter would be very useful.

jcorporation avatar Mar 24 '25 19:03 jcorporation

I don't think it makes sense at all. Maybe you could name an example that demonstrates the usefulness?

MaxKellermann avatar Mar 24 '25 19:03 MaxKellermann

An example could be: List 100 Artists in descending order.

Without a sort parameter a client must fetch all the artists and must implement the sorting and the new window parameter in MPD is useless in this scenario.

jcorporation avatar Mar 24 '25 20:03 jcorporation

How exactly would this command line look like? What other sort options would there be?

MaxKellermann avatar Mar 24 '25 20:03 MaxKellermann

Sorting by the tag we list should be suffice:

list {TYPE} {FILTER} [group {GROUPTYPE}] [window {START:END}] [sort {SORTDIRECTION}]

SORTDIRECTION is asc or desc

Edit: Eventually it is better to not use the sort keyword as it is used differently in other commans. order could be better:

list {TYPE} {FILTER} [group {GROUPTYPE}] [window {START:END}] [order {SORTDIRECTION}]

jcorporation avatar Mar 24 '25 20:03 jcorporation

Sorting by the tag we list should be suffice:

Not quite

  1. any other tag is impossible to sort by
  2. you're slightly wrong - you can only sort the top-most tag, which is not the listed-by tag if there is a group (the list command is more complicated that it seems, but people wanted it that way)

Anyway we agree that only one tag is ever possible, therefore only the direction can possibly be chosen.

But is it really necessary to have descending order? The client can choose a window that's at the bottom, can't it?

Edit: Eventually it is better to not use the sort keyword as it is used differently in other commans. order could be better:

Hm, order seems somewhat ambiguous. Maybe direction?

MaxKellermann avatar Mar 24 '25 21:03 MaxKellermann

But is it really necessary to have descending order? The client can choose a window that's at the bottom, can't it?

The client does not know the bottom index or do I miss anything?

direction is good for me.

jcorporation avatar Mar 24 '25 21:03 jcorporation

I don't think direction is enough as a sort option.

I think users expect sorting to be in linguistic order according to language. See: ICU collation

At the very least case-sensitivity, but also accents and umlauts, language articles and more.

Without a proper sort options, the window is not so useful. Clients have to take the whole list and sort locally according to user preferences. Not only in list command but the others as well.

geneticdrift avatar Mar 27 '25 06:03 geneticdrift

@geneticdrift, you are talking about a very different aspect that is orthogonal to the concept discussed here. It would be possible add a command, say locale that lets the client declare the preferred locale to the server, so MPD can use ICU's locale features to make sorting/comparisons language-specific.

MaxKellermann avatar Mar 27 '25 06:03 MaxKellermann

@geneticdrift : I think your proposal is worth a new feature request.

jcorporation avatar Mar 28 '25 16:03 jcorporation