Finished planning logic: sort the order of groups of variable binding candidates