protected void moveResourceToTop(List<UIComponent> resources, String resource) {
        resources.sort((a, b) -> {
            String nameA = (String) a.getAttributes().get("name");
            String nameB = (String) b.getAttributes().get("name");
            if (nameA != null && nameA.endsWith(resource)) return -1;
            if (nameB != null && nameB.endsWith(resource)) return 1;
            return 0;
        });
    }
Moves a resource component to the top of the resources list based on its name.
This is used to ensure certain resources like theme.css and primeicons.css are loaded first.

@param resources The list of UIComponent resources to sort
@param resource The resource name suffix to move to the top
primefaces/src/main/java/org/primefaces/renderkit/HeadRenderer.java