Custom TCL Sort

I would appreciate any help with this as I am new to TCL. I created a list of lines by executing 'regexp -all -line -inline' + criteria on the output of the CLI command. Each element of this list now ends with a number, and I want to sort the list by this specific numerical ending in each line, but save the rest of the line. A close example is sorting the output of a command ls -laby file size. I tried the following, but this did not work:

lsort -command  "regexp -lineanchor {\d+$}" -integer $list

After spending a day trying to figure it out, I decided to ask you guys. Can you help?

+3
source share
1 answer

, , -command "regexp -lineanchor {\d+$}". regexp -lineanchor {\d+$} 1, .

, -index. :.

lsort -index end -integer {{x y 5} {a b 8} {c c 3} {u u 1} {x y 2}}

:

{u u 1} {x y 2} {c c 3} {x y 5} {a b 8}

, , split , :

lsort -index end -integer [split $data "\n"]
+5

All Articles