more work on sorting subjects, fixes #7630
Merge branch 'dev' into test