(defun BubbleSort (nlst / loopnum lownum next sorted nlst)
(defun loopnum (low lst / )
(if (setq a low
b (cdr lst))
(if (minusp (- (car b) a))
(loopnum (car b) b)
(if b (loopnum a b)))
)
a
)
(while (setq Lownum (car nlst))
(setq next (cdr nlst))
(setq Sorted (cons (loopnum Lownum nlst) Sorted))
(setq nlst (vl-remove (car sorted) nlst))
(if (member Lownum sorted)
(setq nlst (vl-remove lownum nlst))
))
(reverse sorted)
)
(BUBBLESORT '(8 5 2 7 4 3))
(2 3 4 5 7 8 )
(BUBBLESORT '(6 5 3 8 10 25 712 13 37 4 105 ))
(3 4 5 6 8 10 13 25 37 105 712)
(BUBBLESORT '(-1 6 5 3 6 -34 111 3 3 4 1 5 1258 10 23 52.3 6 2015 712 8 13 37 4 105 ))
(-34 -1 1 3 4 5 6 8 10 13 23 37 52.3 105 111 712 1258 2015)
Removes duplicates as well
Still brute force though
should've use (< (car b) a) instead of (minusp (- (car b) a)), what was i thinking!!! it just shows variety i guess
EDIT:
(> (car b) a)<------- retarded (no need for reverse) :loco: