我的名單是:如何排序列表,同時優先考慮數字之前的字母表?
set list {23 12 5 20 one two three four}
預期輸出是遞增的順序,不同的是,字母需要在開始的時候放:
four one three two 12 20 23 5
我試過如下:
# sorting the list in increasing order:
lsort -increasing $list
-> 12 20 23 5 four one three two
# Here i get the result with numbers first as the ascii value of numbers are higher than alphabets.
lsort -decreasing $list
# -> two three one four 5 23 20 12
您是否也想作爲數字排序,而不是作爲字符串的數字嗎? (即12之前5) – 2013-03-18 13:02:07