Fix sorting of logical plan candidate list and ensure the best plan is chosen