Thanks Sir_Fz for this hint. Unfortnately i don't know tcl, but i have a piece of code that can be a good start if some 1 can help to modify it to what i want. I think this code sorts the input file and make everything in a sigle line, like if we give it a c b in separate lines, it will return a b c in a single line in the output file. Me, i want to sort the file, but keep them in separate lines.
proc trivsort {} {
putlog "starting sorting......."
set f [open "input.txt" r]
set triv [read $f]
close $f
set trivlist [split $triv "\n"]
unset triv
lsort -increasing $trivlist
set f [open "output.txt" w]
puts $f $trivlist
close $f
putlog "sorting done.."
}