dag: use a consistent sort order when selecting commits