ENH: updated cycle detection to pop sorted key

`pop_key` will pop an item from the graph that has the fewest dependencies
In the case of a tie, the winners will be sorted alphabetically.

cc @mattpap @asmeurer