Modules A, B, C:
Module B and C extend A, A not having any revision specified.
Module C depends on B using a configuration inherited from A, B will be published as 1.0, C depends on 1.0
In this configuration, it might happen that the ivy:buildlist does not order B and C properly, try with the attached project, run "ant _sort-modules" from build-essentials directory.
For the first time, it sorts correctly, but the module A appears in the local cache. When you run the ant _sort-modules for the second time, the order of A and B is reversed.
What might be happening is that the module A is put to the local cache, but with revision="working@module-inheritance-repository". Module B inherits this revision, and since Module C specifies exact revision "1.0", these two do not match and the dependency is not taken into account while ordering the modules. I think that the revisions of the parent modules should be ignored.
Also, if you specify exact revision for A, e.g. 2.0, which won't match with the dependency specified in C ivy.xml (1.0), there is the same behavior. Only if A would specify 1.0, which matches the dependency, sort order is correct.
I do not see this behavior with Ivy 2.2, where the sort order is always correct.