sort before search