My perl is a bit rusty, so this can certainly be made cleaner. Try:
perl -nE 'BEGIN{$/=""}; @b = split "\n", $_;
@a = shift @b; push @a, sort @b;
push @f, join("\n", @a); END{ say "$_\n" foreach sort @f }' input
Set $/ to the empty string so that perl reads each section as a record. The initial split splits each record on the newlines, and then we construct the array @a by shifting off the first line of the section and then sorting the remaining lines. Construct a string from that and push it onto the array @f. At the end, sort the sections and write output.
You can trim a bit by autosplitting:
perl -F'\n' -a -nE 'BEGIN{$/=""};
push @f, join "\n", shift @F, sort @F;
END{ say "$_\n" foreach sort @f } ' input
or:
perl -00 -F'\n' -a -nE 'push @f, join "\n", shift @F, sort @F}
{print join "\n\n", sort @f' input
The last command is a somewhat weird idiom which takes advantage of the fact that -n puts the command inside an implicit while(<>){...} construct and the first } in the code matches the implicit { while the "unmatched" { matches the implicit }, making it similar to running the final code in an END block.