(defun bubbleUp (n)
(cond
((null n) nil)
((null (cdr n)) n)
((> (car n) (car (cdr n)))
(append (list (car (cdr n))) (bubbleUp (cons (car n) (cdr (cdr n)))))
)
(T (append (list (car n)) (bubbleUp (cdr n))))
)
)
(defun getLast (n)
(cond
((null (cdr n))
(car n)
)
(T
(getLast (cdr n))
)
)
)
(defun getAllButLast (n)
(cond
((null n)
nil
)
((null (cdr n))
nil
)
(T
(cons (car n) (getAllButLast (cdr n)))
)
)
)
(defun sort (n)
(cond
((null n)
nil
)
(T
(append (sort (getAllButLast (bubbleUp n))) (list (getLast (bubbleUp n))))
)
)
)