In order to achieve this you would need to configure the frontend as shown here with dynamicWidgets.
There's an example code sandbox here.
This article contains information about controlling the order of facets in the response: https://support.algolia.com/hc/en-us/articles/9265608786577