added sorting for categories