Would this be the best way to sort a hash and return Hash object (instead of Array):
h = {\"a\"=>1, \"c\"=>3, \"b\"=>2, \"d\"=>4}
# => {\"a\"=
I liked the solution in the earlier post.
I made a mini-class, called it class AlphabeticalHash. It also has a method called ap, which accepts one argument, a Hash, as input: ap variable. Akin to pp (pp variable)
But it will (try and) print in alphabetical list (its keys). Dunno if anyone else wants to use this, it's available as a gem, you can install it as such: gem install alphabetical_hash
For me, this is simple enough. If others need more functionality, let me know, I'll include it into the gem.
EDIT: Credit goes to Peter, who gave me the idea. :)