Question: I use the following command to sort the content of a string

```
set local_object [lsort -dictionary $list_object] 

```

this comand will replace new lines by spaces 

how to avoid that ?

Answer: 
lsort assumes that its argument is a Tcl list. Any whitespace including newlines can separate elements of that list, but will not be preserved in the output. If you want to format the output list with one element per line you could do:

```
set local_object [join [lsort -dictionary $list_object] "\n"]

```
It all depends on how your list is built. Any string can be interpreted as list. All the white spaces are considered as a delimiter if you're treating string as list.

```
set str "d b a\n c"
set lst [lsort -dictionary [split $str " "]]
foreach word $lst {
    puts $word
}

a

b
c
d

```

Split has preserved newline and used single space as a delimiter.