Add a test for Hash::sort()

Closes #3956