improved search sorting options logic