Would you be able to provide a sample dataset and workbook describing your setup?
It would be easier to provide an answer and example that way.
As I understand that you want to choose a variable and want the visualization to get sorted.
We can achieve this using a parameters in tableau. Please follow the below link.
Hoping that you can also relate above link even if your requirement is "Create a Parameter Control to Sort by Measure"
Thanks & Regards