This comparator orders the diffs so that the resulting execution order does not generate errors due to dependencies etc. More specifically:
- 1- create locations wrt hierarchy (highest first)
- 2- delete resources wrt reference graph (shallow first)
- 4- create/update/rename resources wrt both reference graph (deepest first) and operation type (update first). However when deepest-first and update-first results in a conflicting order, the deepest-first order is chosen. For example if R1 is updated, R2 is created, and R1 depends on R2, the deepest-first will return R2 and update-first will return R1. In this case R2 is chosen as first.
- 4- delete locations wrt hierarchy (lowest first)