
$DEFINE min(*)
	$IF($$==1) 
		$(1)
	$ELSE $IF ($(1)>=$(2))
				$CALL(min,$(2,$$))
		  $ELSE $IF($$==2) 
					$(1)
				  $ELSE
					$CALL(min,$(1),$(3,$$))
				  $ENDIF
			$ENDIF
	$ENDIF
$END

$NOSPC(min(5,1,4,3,8,9,0,15,2))

$DEFINE collectless(*)
$IF ($$==1)
$ELSE
	$IF ($EVAL(compare($(2),$(1))<=0))
		$IF ($$==2) 
			$(2) 
		$ELSE 
			$(2) ,$CALL(collectless,$(1),$(3,$$))
		$ENDIF
	$ELSE
		$IF ($$>2)
			$CALL(collectless,$(1),$(3,$$))
		$ENDIF
	$ENDIF
$ENDIF
$END

$DEFINE collectgreat(*)
$IF ($$==1)
$ELSE
	$IF ($EVAL(compare($(2),$(1))>0))
		$IF ($$==2) 
			$(2) 
		$ELSE 
			$(2) ,$CALL(collectgreat,$(1),$(3,$$))
		$ENDIF
	$ELSE
		$IF ($$>2)
			$CALL(collectgreat,$(1),$(3,$$))
		$ENDIF
	$ENDIF
$ENDIF
$END

$DEFINE sort(*)
$IF ($$==0)
$ELSE $IF ($$==1)
	do( $(1) )
$ELSE
	$CALL(sort,$CALL(collectless,$(1),$(2,$$))) do ($(1) )
	$CALL(sort,$CALL(collectgreat,$(1),$(2,$$)))
$ENDIF
$ENDIF
$END


$DEFINE compare(a,b) $GET(1,a)-$GET(1,b) $END

$DEFINE do(a)
$IFNDEF(do_entered) 
 	$DEFINE do_entered() $END 
$ELSE 
	, 
$ENDIF 
a 
$END

$DEFINE tt() 11 $END

$NOSPC($CALL(print,sort((5,a),(1,b),(4,c),(3,d),(8,e),($EVAL(tt-3),t),(9,f),
						(0,g),(15,k),(2,j))))

$GET(2,$GET(1,((a,x),(b,y),(c,z))))

