Fix SortCategories problem