Sort commits topologically when iterating over the history.