I think there is a bug when i 'sort by tags: number of tags'. So when i match the domain i am looking into in the search pane (the one under the OR button) to the 'tags' button domain (next to collect/leave unmatched button), let's say both are changed to 'downloader tags' and 'ascending', then the sorting is correct. I suppose you have to match them, because that way the tags you see are the tags you sort exactly.
The first files have no tags, then when i hold the right arrow key, i can see how the tag list gets more and more populated with tags and the scroll bar in the tag list gets smaller and smaller. That is how it should be.
But when i match the domain of the said buttons to everything else except 'downloader tags' (-> my tags, PTR, all known tags), the sorting doesn't work anymore and is all over the place. In average it might get more and more, but from file to file the number goes up and down.
Now i realized how to fix it though. If i change 'sort by tags: number of tags' to a namespace sorting, a second 'tags' button appears right above the first 'tags' button. This is actually the one that changes the behaviour in the 'sort by tags: number of tags' sorting (which is not visible there), that means 'downloader tags' was activated here, so it coincidentally worked in 'sort by tags:number of tags', which i described in the first paragraph.
So we would need THIS 'tags' button there instead of the one which is there, which seems it doesnt do anything in terms of sorting by number of tags. I think this 'tags' sort button is linked to the collection buttons left of it, so this changes the sorting of 'collecty by' collections.
In short: how to sort by number of tags for 'all known tags'? If it works for you like for me in paragraph 2, then try another domain. Does it still?