When Resource.listChildren() is called on a SyntheticResource the order of children returned by the iterator doesn't match the order of children returned by the ResourceProvider which is the origin of the SyntheticResource. At some point between Resource.listChildren() and ResourceProvider.listChildren() the children get shuffled.
An investigation in Sling resource resolver project revealed that a possible cause of the issue is in org.apache.sling.resourceresolver.impl.helper.ResourceIterator.seek() where SyntheticResource objects are stored in a delayed Map before getting returned. For this map a HashMap is used which doesn't preserve the insertion order of its entries. Using LinkedHashMap for the delayed Map might be the solution for this.