I am currently struggling at sorting data. I searched online and never saw any topics mentioning my issue...
I have files with unordered data like:
1
blank line
3
blank line
2
Which have a blank line in between values. When I use my script, it effectively sorts data but blank lines are on top and values on bottom, like :
blank line
blank line
1
2
3
I would like to have an output like:
1
blank line
2
blank line
3
which preserves the structure of the input.
The command I use is: sort -nk1 filename > newfile
How can I preserve the blank lines in the right places?