Amount Generator: fix sorting by dependency resolution

The attempt to make sorting stable in commit
28698f353b588b6152dd175debbaf73a4d522525
was broken because there may be pairs of items that can't be compared,
and list.sort() relies on < transitivity.