To sort file in place, try:
echo "$(sort your_file)" > your_file
As explained in other answers, you cannot directly redirect the output back to the input file. But you can evaluate the sort
command first and then redirect it back to the original file. In this way you can implement in-place sort.
Similarly, you can also apply this trick to other command like paste
to implement row-wise appending.