Here is a merge sort. The list of 50 items seems to crash in the Z machine (though I get no message, it just terminates), so that is commented out, but it works in the debugger. I guess it uses too much memory.
(program entry point)
(sort and print [])
(sort and print [5])
(sort and print [6 2])
(sort and print [1 2 3 4 5 7 8 9 6])
(sort and print [9 8 7 6 4 3 2 5 1])
(sort and print [7 9 3 1 4 8 3 9 4])
%% (sort and print [12 14 42 8 41 26 37 2 32 43 3 6 24 19 45 48 11 23 38
%% 20 27 39 34 9 29 17 30 13 46 7 10 22 28 33 4 40 1 25
%% 5 49 31 16 18 15 21 44 36 50 47 35])
(sort and print $List)
(sort $List into $Sorted)
Sorted: $Sorted (line)
(or)
Failed to sort: $List (line)
(sort [] into [])
(sort [$A] into [$A])
(sort [$A $B | $Tail] into $Out)
(separate [$A $B | $Tail] into $A2 $B2)
(sort $A2 into $A3)
(sort $B2 into $B3)
(merge $A3 $B3 into $Out)
(separate [] into [] [])
(separate [$A] into [$A] [])
(separate [$A $B | $Tail] into [$A | $A_tail] [$B | $B_tail])
(separate $Tail into $A_tail $B_tail)
(merge $A [] into $A)
(merge [] $B into $B)
(merge [$A | $A_tail] [$B | $B_tail] into [$Head | $Tail])
(if) ($A < $B)
(then) ($Head = $A) (merge $A_tail [$B | $B_tail] into $Tail)
(else) ($Head = $B) (merge [$A | $A_tail] $B_tail into $Tail)
(endif)