Fix identifier comparison, sort stability.

I had taken some pains to define a stable sort within ranks in the
topological sort routine...except that one of the elements I'd
included is the target identifier, and cobble.Ident didn't define
an ordering.

What happens if you compare something in Python that doesn't define
an ordering?  Python makes an ordering up.  It appears to be based
on object address.

While I consider this a serious language flaw, it's a credit to
Python's *implementation* that I didn't notice this immediately.
The sort is stable across executions of Cobble on a given machine.
Its instability shows only when Cobble is refactored or modified
internally, which presumably affects the allocation pattern.

Anyway.  This should eliminate some portion of the spurious rebuilds,
and make the build.ninja file significantly easier to read.

In case it wasn't apparent from the description above, this change
will force at least a relink, and often a rebuild.
Factor Ninja file generation out of wrapper.py.