Re: feature proposal: expand associative arrays in lexicographic order ...
Chet Ramey <[email protected]>
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <[email protected]> |
On 8/25/26 10:06 AM, Stan Marsh wrote: > FWIW, I could not figure out how to use the bash "asort" extension. The following: array=( zero one two three four five six) declare -p array # sort array in place by value lexicographically asort array declare -p array array=( zero one two three four five six) # sort array by value lexicographically and assign the indices in array # corresponding to the sorted order to new asort -i new array declare -p new produces declare -a array=([0]="zero" [1]="one" [2]="two" [3]="three" [4]="four" [5]="five" [6]="six") declare -a array=([0]="five" [1]="four" [2]="one" [3]="six" [4]="three" [5]="two" [6]="zero") declare -a new=([0]="5" [1]="4" [2]="1" [3]="6" [4]="3" [5]="2" [6]="0") Does this help? -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/