some refactoring
+ added SortDescriptor to sort categories according to priority.