[Richard Suchenwirth] 2005-10-04 - Collation is "the logical ordering of character or wide-character strings according to defined precedence rules. These rules identify a collation sequence between the collating elements, and such additional rules that can be used to order strings consisting of multiple collating elements." Tcl's [lsort] sorts according to numerical Unicode values, which may not be correct in some locales. For instance, in Portuguese, accented letters should sort as if they weren't, but in Unicode sequence come after "z". The following oversimplified code takes a map in which collation differences can be listed as {from to from to...}, sorts the mapped items, and retrieves only the original elements: proc collatesort {list map} { set l2 {} foreach e $list { lappend l2 [list $e [string map $map $e]] } set res {} foreach e [lsort -index 1 $l2] {lappend res [lindex $e 0]} set res } Testing, Portuguese: % collatesort {ab ãc ãd ae} {ã a} ab ãc ãd ae Spanish: % collatesort {llano luxaciòn leche} {ll lzz} leche luxaciòn llano German: % lsort {Bar Bär Bor} Bar Bor Bär ---- [Category i18n] | [Arts and crafts of Tcl-Tk programming] 65 % collatesort {Bar Bär Bor} {ä ae} Bär Bar Bor