fixed sort and search bugs