Issue #3449743 by catch: Try to optimize test ordering when run-tests.sh is used with a mixture of test types
(cherry picked from commit 17ec849e)
Closes #3458990