Repository: PowerToys
Issue: PowerToys Run Plugin interface cannot enforce result order
Labels: Issue-Bug,Needs-Triage,Needs-Team-Response

### Microsoft PowerToys version

0.87.0

### Installation method

Microsoft Store

### Running as admin

Yes

### Area(s) with issue?

PowerToys Run

### Steps to reproduce

I'm not sure whether it is a bug or something weird that is either not documented or I could not find the documentation for, but here we go:

When making a plugin, it is not possible to fix the order of the results from the plugin side for specific sets of searches.
Let's take a specific example, which is a barebone plugin (not global, no result tuning [although] that does not matter because it is a user setting which should be possible to ignore on purpose), and the following Query function:

```c#
        public List<Result> Query(Query query) {
            List<Result> results = [];
            string[] items = query.Search.Split(";");
            for (int index = 0; index < items.Length; index++) {
                results.Add(new Result {
                    Title = items[index],
                    Score = items.Length - index,
                    SelectedCount = 0,
                    Action = actionContext => {
                        this.Context.API.ChangeQuery(query.RawQuery, true);
                        return false;
                    },
                });
                results.Last().SubTitle = $"{Context.CurrentPluginMetadata.WeightBoost} - {results.Last().Score} - {results.Last().SelectedCount}";
            }

            return results;
        }
```

The interface for ordering, as far as I know, is the `Score`, and it does work until something is selected, which in general makes sense because of the order tuning, but the issue is that the order tuning cannot be avoided from the plugin side properly when a set of results are meant to have a strict order (I want to have it most of the time, but sometimes I to provide a strict order)

As it can be seen above, I tried to also set the `SelectedCount` based on a snippet I found in the PowerToys source code (PowerLauncher > ResultsViewModel > Sort), and while I did not spend much time on it, I assume that is more or less what is happening (please correct me if I'm wrong)
![Image](https://github.com/user-attachments/assets/deec289b-ac0f-40bc-b360-2d22c1dbe14a)

The issue is that while I have no weight boost and have a good score the `SelectedCount` seems to have no effect because as I select something, it jumps to the top regardless, and that persists, even though the results are recreated with 0 `SelectedCount`, so I don't get what the `SelectedCount` does at all (which is mostly why I marked this as a bug, but it's the smaller issue)

Technically I could multiply the scores, but that's just a weird workaround, which works until it doesn't as the user selects enough stuff, and making the user change the tuning is not a good solution, especially when in some cases the tuning is preferred within the same plugin.

In case it is not a bug, and the method to do fixed ordering exists, I'd appreciate a link to the docs, and if there are no docs, then I'd appreciate help with this, and some docs to be made on the plugin and result interface because I can't find docs when it comes to doing anything meaningful

### ✔️ Expected Behavior

The code above does this regardless of selecting items
![Image](https://github.com/user-attachments/assets/a14fe9d1-6144-4e1a-a63d-f0f2f29fd29e)


### ❌ Actual Behavior

The code above does this after selecting items
![Image](https://github.com/user-attachments/assets/b8af5861-d6e9-4e6f-8e29-6385e6944bb6)


### Other Software

_No response_