...
In more detail, this looks like:
First level sort: by the provision to which the amendment relates (using the ukl:targetProvision attribute)
Sort by the order that provisions appear in the Bill, as adjusted by the Order of Consideration (Bill is published version to which the amendments relate).
...
Amendments to amendments that have a @ukl:targetProvision="amnd_z" should appear after their target amendment (identified using the number expressed as "z" in the example ukl:targetProvision="amnd_z").
Second level sort: by whether amendment is before the target provision, to the target provision or after it (using the ukl:location attribute)
Sort by values in the following order: before, (empty), after
Third level sort: by position on page (using the ukl:targetPage attribute)
Sort in ascending order by page (p_x), then line (ln_x), then column (col_x, if included) e.g.
Amendments with empty ukl:targetPage (i.e. an amendment to leave out clause/schedule) go last
Fourth level sort (using the ukl:targetSortKey attribute)
Amendments appear in sort code order ascending - using alphanumeric values e.g. M1, M2, M3... or 20, 30, 40 or 1, 2, 3
...