sort file inline

We can sort file by using sort command for example:
$ sort a.txt
# or
$ cat a.txt | sort
But this will only output to stdout. Some time you want the file to be sorted. Instead you can do
$ sort a.txt -o a.txt
note that this DOEST work and it will TRUNCATE the file
$ sort a.txt > a.txt