Having an array of this type:
declare -A ARRAY ARRAY[0,0]=число ARRAY[0,1]='строка' ARRAY[1,0]=число ARRAY[1,1]='строка' # ... ARRAY[$N,0]=число ARRAY[$N,1]='строка' It is necessary to sort it by numbers (in reverse order, but I think it does not matter) and get only a list of strings. That is, with such data:
[ 1, 'd' ] [ 4, 'a' ] [ 2, 'c' ] [ 3, 'b' ] The output should be:
[ 'a','b','c','d' ] While the head climbs completely stupid:
DATA="" for(( i = 0; i < $N; i++ )); do DATA+="${ARRAY[$i,0]} ${ARRAY[$i,1]}"$'\n' done echo "$DATA" | sort -gr | sed -e 's/^[0-9 ]*//g' But for some reason it does not seem like the best option :)