Fixed 'sort by' bug