0 Members and 1 Guest are viewing this topic.
Quote from: Lee Mac on April 29, 2019, 12:59:54 PMQuote from: ronjonp on April 29, 2019, 12:37:24 PMI'm sure this logic is flawed and horribly inefficient but it's the first thing that came to mind Add ("B.10" 66.73 "Regular") to your list DOH! That's some strange numbering since "A.05" is formatted correctly.
Quote from: ronjonp on April 29, 2019, 12:37:24 PMI'm sure this logic is flawed and horribly inefficient but it's the first thing that came to mind Add ("B.10" 66.73 "Regular") to your list
I'm sure this logic is flawed and horribly inefficient but it's the first thing that came to mind
Consider the following function based on the code from my earlier post -Code - Auto/Visual Lisp: [Select](defun mysort ( l ) (vl-sort l (function (lambda ( a b / x y ) (if (= (car a) (car b)) (< (cadr a) (cadr b)) (progn (setq a (LM:splitstring (car a)) b (LM:splitstring (car b)) ) (while (and (setq x (car a)) (setq y (car b)) (= x y) ) (setq a (cdr a) b (cdr b) ) ) (cond ( (null x) b) ( (null y) nil) ( (and (numberp x) (numberp y)) (< x y)) ( (numberp x)) ( (numberp y) nil) ( (< x y)) ) ) ) ) ) )) ;; Split String - Lee Mac;; Splits a string into a list of text and numbers (defun LM:splitstring ( str ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (apply 'append (mapcar (function (lambda ( a b c ) (cond ( (= 92 b) (list 32 34 92 b 34 32) ) ( (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) (list b) ) ( (list 32 34 b 34 32)) ) ) ) (cons nil l) l (append (cdr l) '(( ))) ) ) ) ")" ) ) ) (vl-string->list str) ))Example:Code - Auto/Visual Lisp: [Select]_$ (mysort '(("A.05" 12.34 "Regular") ("A.10" 34.54 "BigSize") ("B.9" 66.73 "Regular") ("A.10" 12.12 "BigSize") ("A.05" 12.55 "BigSize")))(("A.05" 12.34 "Regular") ("A.05" 12.55 "BigSize") ("A.10" 12.12 "BigSize") ("A.10" 34.54 "BigSize") ("B.9" 66.73 "Regular"))