1

I have an array :

a=("toto.blabla" "toto.dlabla" "totodlabla")

then I do :

IFS=$'\n'; echo "${a[*]}" | sort -d; unset IFS

but the result is :

toto.blabla
totodlabla
toto.dlabla

instead of :

toto.blabla
toto.dlabla
totodlabla

Why sort command do not treat dots ?

Best regards,

Olivier

choroba
  • 231,213
  • 25
  • 204
  • 289
Olivier
  • 13
  • 2

2 Answers2

3

When sorting, your current locale is influencing the order. If you want locale independent order, use the C locale:

IFS=$'\n'; echo "${a[*]}" | LC_ALL=C sort -d; unset IFS

Setting LC_COLLATE should be enough, in fact.

choroba
  • 231,213
  • 25
  • 204
  • 289
0

Thank you, it works :-)

With LC_ALL=C but not with LC_COLLATE=C

Olivier
  • 13
  • 2