Posted to tcl by kbk at Sat Dec 19 19:44:11 GMT 2009view raw
- set list {peter(3) paul(2) mary(1)}
- set keylist {}
- foreach elt $list {
- set value 0; #guard against malformed entries
- regexp {[(](.*)[)]} $elt -> value
- lappend keylist [list $value $elt]
- }
- set outlist {}
- foreach pair [lsort -integer -index 0 $keylist] {
- lappend outlist [lindex $pair 1]
- }
- puts $outlist