(setq lst '(("plywood" "10x17" 5) ("plywood" "10x12" 2) ("plywood" "14x12" 14) ("plywood" "14x11" 4)
("steel" "4x4" 8) ("beam" "12x12" 9) ("beam" "12x10" 6) ("beam" "12x7" 3)
))
Thank you for that nice work , but the result still different although it is very close to the correct result .
Lee is just fine, only I would change this line :Code - Auto/Visual Lisp: [Select]
to this :Code - Auto/Visual Lisp: [Select]
Hello guys .
I have a list of elements and I would like to resort them according to the next list .Code: [Select](setq lst '(("plywood" "10x17" 5) ("plywood" "10x12" 2) ("plywood" "14x12" 14) ("plywood" "14x11" 4)
("steel" "4x4" 8) ("beam" "12x12" 9) ("beam" "12x10" 6) ("beam" "12x7" 3)
))
The sorting must be according to the second number after the x operator in the second element of each pair without changing their
the other pair's locations .
The result resorted like this
(setq lst '(("plywood" "10x12" 2) ("plywood" "10x17" 5) ("plywood" "14x11" 4) ("plywood" "14x12" 14)
("steel" "4x4" 8 ) ("beam" "12x7" 3) ("beam" "12x10" 6) ("beam" "12x12" 9)
))
I Hope that is clear and easy enough to you masters to help me with it , and please do not hesitate to ask for any clarification . :-)
Thanks in advance
Thank you for the suggestion Marko, however, firstly your suggestion would be incorrect for dimensions with varying numbers of digits given the OP's requirements, e.g. sorting 4x4, 4x10 & 5x4 would result in 4x4, 5x4, 4x10; but nevertheless, I was under the understanding that the OP wanted to retain the order of the first digit, rather than sort it.
Command: (formatcadrbydigits lst)
(("plywood" "10x17" 5) ("plywood" "10x12" 2) ("plywood" "14x12" 14) ("plywood"
"14x11" 4) ("steel" "04x04" 8) ("beam" "12x12" 9) ("beam" "12x10" 6) ("beam"
"12x07" 3))
Command: (formatcadrbydigitsback (formatcadrbydigits lst))
(("plywood" "10x17" 5) ("plywood" "10x12" 2) ("plywood" "14x12" 14) ("plywood"
"14x11" 4) ("steel" "4x4" 8) ("beam" "12x12" 9) ("beam" "12x10" 6) ("beam"
"12x7" 3))
(formatcadrbydigitsback (LM:mysort (formatcadrbydigits lst)))
Command: (formatcadrbydigitsback (LM:mysort (formatcadrbydigits lst)))
(("plywood" "10x12" 2) ("plywood" "10x17" 5) ("plywood" "14x11" 4) ("plywood"
"14x12" 14) ("steel" "4x4" 8) ("beam" "12x7" 3) ("beam" "12x10" 6) ("beam"
"12x12" 9))
my version for revers sort:Code - Auto/Visual Lisp: [Select]