I have a script which reads input and counts the char occurrence. It's based on an array:parse_stream () {    while read -n 1 char; do        if [[ -n $char ]]; then            ((count++))            ((chars[\\$char]++))        fi    done}It prints a simple report reading the array:print_results () {    { for i in ${!chars[@]}; do        echo -e $i \t  ${chars[$i]}    done } | sort}The results I get keep alphabetical order, but with intermingled low and upper case letters:0    3362[    1/    1213:    1628_    1681    7282*    23372    3922+    243    22614    2042.    5085    1624>    5756    1879-    71287    13458    18959    853A    1a    2610b    578c    1430C    2D    1d    1179E    2e    3166F    1f    853G    1g    962H    1h    633I    11i    2955j    254k    1157l    2619M    13m    1915n    1590O    1o    10983p    2127P    3Q    11q    118r    14003S    1s    2559T    2t    8165u    1067v    595w    4556X    4x    7802y    660z    193    48One time, the upper case comes first, another time it's the lower case. Is there any way to fix this?The numbers are in mess too... But this can get sorted with sort (sometimes... why?...). Ubuntu here, if that matters.You can see the whole script here.UPDATEI applied LANG=pl_PL.UTF-8 sort to the function in the script. It's not that garbled now, but still occurs with low and uppercase.0    33591    72812    39313    22584    20465    16246    18827    13468    18929    846A    1         #uppera    2607      #then lowerb    578c    1430      #lowerC    2         #then upperD    1...etc...My normal settings are different, but inherited by the subshell:tomasz@tomasz-Latitude-E4200:~$ echo $LANGen_US.UTF-8tomasz@tomasz-Latitude-E4200:~$ (echo $LANG)en_US.UTF-8Which puts the normal or previous behaviour of sort in a difficult light.Anyhow, the upper and lower cases also stay garbled after I use the LANG definition explicitly in additional sorting, ie:ll /usr/bin | charstat | LANG=pl_PL.UTF-8 sortThis again produces this sequence:A    1a    2607b    578c    1430C    2UPDATE$ localeLANG=en_US.UTF-8LANGUAGE=en_USLC_CTYPE=en_US.UTF-8LC_NUMERIC=pl_PL.UTF-8LC_TIME=pl_PL.UTF-8LC_COLLATE=en_US.UTF-8LC_MONETARY=pl_PL.UTF-8LC_MESSAGES=en_US.UTF-8LC_PAPER=pl_PL.UTF-8LC_NAME=pl_PL.UTF-8LC_ADDRESS=pl_PL.UTF-8LC_TELEPHONE=pl_PL.UTF-8LC_MEASUREMENT=pl_PL.UTF-8LC_IDENTIFICATION=pl_PL.UTF-8LC_ALL=
Bash collation strength (capital chars vs small)
bash;ubuntu;sort