I would suggest using ivy-prescient. It is a package that provides sorting and filtering for ivy.
After installing it, you enable it with ivy-prescient-mode.
For more details on it's usage see its usage README section.
This is a solution that doesn't require the entire block to be sorted, instead it moved the line up/down until it's sorted compared to lines directly above/below it.
(defun sort-line-in-block ()
"Sort the current line relative to surrounding lines in the same block.
Blocks are delimited by empty lines.
Needs some helper functions. Requested command at bottom:
(setq empty-line-p-chars "^[ \t\r]*$")
(defun empty-line-p ()
"Return t if cursor is at an empty line, nil otherwise."
(defun ar-beginning-of-indent ()
"Go to the beginning of a section of equal indent."