- the page used to assume that tree_sortkey was not unique, but it is. Implement a silly swapping logic to overcome this - introduce input validation - rework db idioms - fix indentation
Notice that the whole script relies on the tree_sortkey column on cr_items, which does not seem to exist on Oracle.