algorithum sorted for candidate match