Fix infinite loop in RecipeSorter for real

Same bug as before, but in a different place.