I think this sorting function would most surely lead to troubles in case of circular dependencies, i.e. if the dependency graph is not a DAG.
What would be needed for that is something like what's done in `Query.dependencies_subset`, but including version information (for both `a` and `b`), and marking as `nonordered` the cases where `a` and `b` mutually depend on each other (note: this last event, though admissible in principle, is a sign of poor choices in METADATA, and probably quite rare; not having a DAG is however a more concrete possibility, e.g. if some package `a` used to depend on `b`  and after some time and code refactoring the dependency relation gets reverted).

I'm also concerned about this relation not seeming to be a total order even on simple DAGs, e.g. say we have packages `A`, `B` and `C`, and a single dependency, namely that `C` depends on `A`; then we have `C < A` (because of the dependency relation), `A < B` and `B < C` (lexicographic), so it's circular and not transitive. Am I missing something?