Sorting selected state of category buttons