Any reason you can't (or don't want to) use the sort cmd?
code:
shell '%comspec% /c type sort.txt | sort > sorted.txt'