/* Sort a1,...,aN */ proc ord (p:int*,q:int*) returns (perm:bool) var tmp:int; begin perm = false; if (*p > *q) then (*p,*q) = (*q,*p); perm = true; endif; end var stable:bool,perm:bool, a1:int,a2:int,a3:int,a4:int,a5:int,a6:int,a7:int,a8:int, p_low:int*,p_high:int*; begin stable = false; while (not stable) do stable = true; p_high = &a1; p_low = p_high; p_high = &a2; perm = ord(p_low,p_high); stable = stable and not perm; p_low = p_high; p_high = &a3; perm = ord(p_low,p_high); stable = stable and not perm; p_low = p_high; p_high = &a4; perm = ord(p_low,p_high); stable = stable and not perm; p_low = p_high; p_high = &a5; perm = ord(p_low,p_high); stable = stable and not perm; p_low = p_high; p_high = &a6; perm = ord(p_low,p_high); stable = stable and not perm; p_low = p_high; p_high = &a7; perm = ord(p_low,p_high); stable = stable and not perm; p_low = p_high; p_high = &a8; perm = ord(p_low,p_high); stable = stable and not perm; done; end