Sort multiSelect values by attribute

I use a multiselect box to let users search for keywords and filter companies that mention them.
As the users type, I run a SQL query on Postgres to give me the most common keywords that match the inputValue, sorted by how many companies match each keyword.


However, that order is not preserved and Retool sorts those values by the similarity to the inputValue.

I'd like to display keywords with a lot of companies first, because they're more relevant. Is there a way to do this?


@xoel Can you set your query to order by "numberofcompanies" ASC ?

Yes, the query is set like that but that order doesn't hold when you type values. It seems like Retool sorts the elements by text similarity with the inputValue or something like that.

Any updates on this?


Great feedback! Thanks for sharing a specific example. We have an internal ticket to track this request & I'll post here when we're able to ship a fix