When I am trying to sort a file and save the sorted output in itself, like this
sort file1 > file1;
the contents of the file1 is getting
Redirection has higher precedence. So in the first case, > file1 executes first and empties the file.