Fixed sorting of category assignments