Lee,
The first (while) loop is very impressive!
Looks like it works similairly to
vl-some, so overall your suggestion
I think will average of 1.5 iteration, while mine either 1 either 2.
That thread looks interesting indeed.
However David was right, so I think this initial comparsion might be faster (and after that iterate once) :
(defun SortEnamesByHex
(e1 e2
) )
)
); defun SortEnamesByHex
; Select 2 entities:
<Entity name: 7ff6cd5073e0>
<Entity name: 7ff6cd507440>
_$ (SortEnamesByHex e1 e2)
(<Entity name: 7ff6cd5073e0> <Entity name: 7ff6cd507440>) ; <- Result
; Now select the same 2 entities, but reverse:
<Entity name: 7ff6cd507440>
<Entity name: 7ff6cd5073e0>
_$ (SortEnamesByHex e1 e2)
(<Entity name: 7ff6cd5073e0> <Entity name: 7ff6cd507440>) ; <- Result
_$
Where these are from Kent Cooper:
; http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/decimal-to-hexadecimal/td-p/2873916
;; int2hex.lsp
;; Base-10 Integer to Hexadecimal converter.
;; Accepts positive or negative integer argument, including 0.
;; Rejects non-integer argument with Alert.
;; Kent Cooper, January 2011
(defun int2hex
(int
/ power neg int result div remain posval
) (setq div
(expt 16 power
) remain
(rem int div
) posval
(/ remain
(expt 16 (1- power
))) int
(- int remain
) result
(strcat (if (< posval
10) (itoa posval
) (chr (+ 55 posval
)) ) result
) power
(1+ power
) ); end setq
); end while
(strcat (if neg
"-" "") (if (= result
"") "0" result
) ) ); end defun - int2hex
;; hex2int.lsp
;; Hexadecimal to base-10 Integer converter [e.g. for entity handles]
;; Modified/simplified from Frank Oquendo's (basetodecimal) function.
;; Added negative-argument capability and argument validity controls.
;; Kent Cooper, January 2011
(defun hex2int
(hndl
/ result neg power tmp
) ); end if
); end setq
); end while
(if neg
(- result
) result
) ); end defun - hex2int
But I prefer yours, since I don't like overwhelming the main code with too many subfunctions - leaving it as an alternative for someone.
Ignore my previous post, I was indeed confused by the comment.
It was my fault Roy, sorry.