Sort DIVs based on second class and then sort alphabetically per class based on inner text

EDIT: Solved partially with the solution below. But for some reason, the solution below would either only correctly sort everything alphabetically based on the label, or sort it based on the category, but combination of both didn't work in my case. So instead I used the first part, that sorts everything alphabetically, and then used a for loop to manipulate per category like this:

I'm trying to sort DIVs using class name to first order items per category and then order them alphabetically within each category. But I have too many classnames and I can't seem to figure out how to do this. I will confess that this is above my skillset and I just don't know how to do this at all. I know it would require putting few functions together, but I just don't know where to start.