An efficient way to order content in controller [Spring Boot]
Well, you found a workable solution.
One thing that strikes out at me is, that you expose the inner structure of your
ContentOrderMap by accessing orderMap.categoriesByOrderType.get(categoriesOrderType) directly.
The inner map categoriesByOrderType is an implementation detail, which you should not make
known in the public interface. Rather give ContentOrderMap a direct method which returns the page (and while we are at it: change the name, as nobody should care about the class being or containing a map.)
A problem remains, which is: changes will not be local at one place. When you add a new OrderType,
you have to extend the OrderType enum and the ContentOrderMap and the CategoryRepository.
Frankly, you'll not find a way to solve this problem in a 100% clean way, as it concerns the interface
(i.e. the REST service), and the database, so if you assemble your actual definition of a type and
the data storage effect it has in one place, you will have mixed responsibilities in that place.
However, if you think this mixing of responsibilities is bearable (everything is a tradeoff in software
engineering ;-)) you might think about harnessing the power of the java enum, which can implement an
interface. Something along the lines of:
public enum OrderType {
    DEFAULT(&quot;select c.* from whatever order by whatever&quot;),
    POST_COUNT_DESC(&quot;select c.* from whatever order by something else&quot;),
    ....;
    
    private final String query;
    
    private OrderType(String query) {
        this.query = query;
    }
    
    public String getQuery() {
        return query;
    }
}

This way, you only have to extend the enum, pass the constant on into your repository, and then do
whatever you need to do with the contained query.
Another alternative is, using your container. I'm not using spring, but there must be something along
the lines of a CDI Instance&lt;&gt;, which gives you a list of all implementations of a given interface.
In a CDI world, you could declare an interface:
public interface OrderHandler {
    public boolean handlesType(String orderType); // no enum, in the end REST sends you a string anyway
    public Page&lt;Category&gt; getResult(Pageable pageable);
}

Then write your different implementations of these interfaces, and get all of them via:
@Inject
Instance&lt;OrderHandler&gt; orderHandlers;

...

for (OrderHandler orderHandler : orderHandlers) {
    if (orderHandler.handlesType(myParameter)) {
        orderHandler.getResult(...);
    }
}

As I said, there must be something equivalent in spring.