The deep-less-than($A, $B) algorithm used in the specification of fn:sort is incomplete. It does not properly handle the case where $B is empty and $A is not. In general it will return () in such cases, which could be interpreted as a false result, but in at least one case it returns true, specifically when comparing (NaN) to (). So deep-less-than(NaN, ()) and deep-less-than((), NaN) are both true, which makes the sort liable to non-termination.
The deep-less-than($A, $B) algorithm used in the specification of fn:sort is incomplete. It does not properly handle the case where $B is empty and $A is not. In general it will return () in such cases, which could be interpreted as a false result, but in at least one case it returns true, specifically when comparing (NaN) to (). So deep-less-than(NaN, ()) and deep-less-than((), NaN) are both true, which makes the sort liable to non-termination.