Update sorting logic and minor fixes.

Closes #3585300

Merge request reports

Loading