I have a file of several sections, each section start with specific title but all of them ending with the same string, I want to sort the file sections according to the titles without sorting the content of each section (i.e. take the whole section as one block) there is also a blank line between each two section, to clarify the idea if the input is as
string5
z
y
x
string
string2
x
z
y
f
string
the desired output would be as
string2
x
z
y
f
string
string5
z
y
x
string