From: Ruby Baby Date: 2004-03-03T14:22:44+09:00 Subject: why are Hashes so unsorted? what's your solution? I try to avoid questions like "Why doesn't Ruby do what ___ does?" But I'm stumped by hashes and asking for help to find a new solution. I use MySQL databases a lot. Let's say I have a query to find the top-selling albums in my store: SELECT sku, artistname, albumtitle, sold FROM albums ORDER BY sold DESC LIMIT 20; When I get the hash of results from the database, I'm used to making the "sku" the hash key since it's the only unique identifier. A perfect hash key. Used everywhere by my iteration methods. In PHP, this is no problem. I get the hash, and I can do the "each" iteration on it, and get my top-selling albums in order. In Ruby, it's an unordered jumble. Why is that? And what do you think is the Ruby way solution for what I need to do? (The simple query I gave above was much simpler, but I have lots and lots of MySQL queries where I want the results to come back in the order that MySQL gave them, but with full access to the hash results.) Thanks!