Adding a function to sort a hash by keys, with an option to sort recursively