Group: comp.lang.tcl


Subject: "lsort -indices"
From: ZB
Date: 11/6/2007 11:58:46 PM
Another example: set a {x u w a i e} lsort -indices $a - gives: 3 5 4 1 2 0 set b [lsort $a] - gives: a e i u w x (properly sorted list) lsort -indices $b - gives: 0 1 2 3 4 5 (properly ascending indices) Pay attention, that before and after sorting the elements have different indices. Either there's something wrong - or I don't understand, how it should work with "-indices" option. My assumption was, that it returns a list of integers, which will reflect the order of elements AFTER the list will be sorted. But, as you can see above, in unsorted list x has index 3, and in the sorted it has (proper) index 5. "a" had index 1 (why?) - after sorting it has (proper) index 0. In my opinion the indices should be exactly the same, only their order should be changed. Am I wrong? So, how does it work, actually? -- ZB