Posted to tcl by kostix at Sun Mar 11 15:47:08 GMT 2007view raw
- proc histool::sort_jids3 {jids args} {
- set order {server node resource}
- foreach {opt val} $args {
- switch -- $opt {
- -order { set order $val }
- default { error "invalid option: $opt" }
- }
- }
- set norder {}
- foreach part {node server resource} {
- lappend norder [lsearch $order $part]
- }
- set items {}
- foreach jid $jids {
- set parts [list \
- [node_from_jid $jid] \
- [server_from_jid $jid] \
- [resource_from_jid $jid] \
- ]
- set ordered [list \
- [lindex $parts [lindex $norder 0]] \
- [lindex $parts [lindex $norder 1]] \
- [lindex $parts [lindex $norder 2]] \
- ]
- set pat [join $ordered \u0000]]
- lappend items [list $pat $jid]
- }
- set sorted {}
- foreach item [lsort -index 0 $items] {
- lappend sorted [lindex $item 1]
- }
- set sorted
- }