I have a file of different sections separated by blank lines, I want to sort all section ascendingly depending on the 4th value of the 1st line of each section keeping the body of each section as it is without modification.
example input
PT2 energy = 7.135 eV ( -459.5928710 au) ( 57545.0 cm-1) (R=4)
22u22d00 3->6 : -0.535 (0.286)
22202200 4-->6 : -0.344 (0.119)
222u200d 4->8 : 0.256 (0.065)
222u2d00 4->6 : -0.254 (0.065)
R=4 TDM-form-state 1= 0.2702 -0.2855 -0.5610 TDM= 0.69 f: 0.082
PT2 energy = 7.018 eV ( -459.5971543 au) ( 56605.0 cm-1) (R=5)
22u220d0 3->7 : -0.396 (0.156)
222u2d00 4->6 : 0.352 (0.124)
22220ud0 5-->6,7 : 0.326 (0.106)
2222u0d0 5->7 : 0.303 (0.092)
2222u00d 5->8 : 0.271 (0.073)
222ud020 4,5-->7 : 0.267 (0.071)
22u22d00 3->6 : -0.229 (0.052)
R=5 TDM-form-state 1= 0.0860 -0.1785 -0.5446 TDM= 0.58 f: 0.058
PT2 energy = 6.552 eV ( -459.6143027 au) ( 52841.3 cm-1) (R=6)
222u20d0 4->7 : -0.612 (0.374)
2222ud00 5->6 : -0.499 (0.249)
222udud0 4,5-->6,7 : -0.271 (0.074)
R=6 TDM-form-state 1= -0.2916 -0.0544 -2.1475 TDM= 2.17 f: 0.754
outout
PT2 energy = 6.552 eV ( -459.6143027 au) ( 52841.3 cm-1) (R=6)
222u20d0 4->7 : -0.612 (0.374)
2222ud00 5->6 : -0.499 (0.249)
222udud0 4,5-->6,7 : -0.271 (0.074)
R=6 TDM-form-state 1= -0.2916 -0.0544 -2.1475 TDM= 2.17 f: 0.754
PT2 energy = 7.018 eV ( -459.5971543 au) ( 56605.0 cm-1) (R=5)
22u220d0 3->7 : -0.396 (0.156)
222u2d00 4->6 : 0.352 (0.124)
22220ud0 5-->6,7 : 0.326 (0.106)
2222u0d0 5->7 : 0.303 (0.092)
2222u00d 5->8 : 0.271 (0.073)
222ud020 4,5-->7 : 0.267 (0.071)
22u22d00 3->6 : -0.229 (0.052)
R=5 TDM-form-state 1= 0.0860 -0.1785 -0.5446 TDM= 0.58 f: 0.058
PT2 energy = 7.135 eV ( -459.5928710 au) ( 57545.0 cm-1) (R=4)
22u22d00 3->6 : -0.535 (0.286)
22202200 4-->6 : -0.344 (0.119)
222u200d 4->8 : 0.256 (0.065)
222u2d00 4->6 : -0.254 (0.065)
R=4 TDM-form-state 1= 0.2702 -0.2855 -0.5610 TDM= 0.69 f: 0.082
I tried with
sort -n -k4 file
but this operated on all the file and destroy the sections