Added Category sort function