Apply the filter when sorting