improved search sorting options logic
Merge branch 'master' into next