Compare two fragment objects and order such that fragments in different documents
are grouped separately and so that the fragments are ordered from the closest to the end
of the document in document order to the closest to the beginning in document order.
Fragments are sorted:
- in INCREASING alphanumeric ordering of the URI of the document that the fragment belongs to; then
- in INCREASING order of the index of their parent fragment with root fragments being ordered first of all; then
- in DECREASING order of the XPath to the containing element in the parent fragment; then
- in INCREASING order of the fragment index which implies being in increasing order of the number of preceding sibling fragments.
This sorting rule implies that a set of child fragments will be sorted into the order
necessary for insertion into a parent fragment without the insertion of child fragments
causing the later fragment insertions to be done in the wrong place. This is because
the fragment insertions will be done from the end of the parent fragment, in document order
to the beginning of the parent fragment, again in document order.