sorting a hash by key value

M

Me

I have a hash (of a hashes) that has data like this
table1->table_name
->table_size
table2->table_name
->table_size
 
J

Jürgen Exner

Me wrote:
[...]
I need to sort the hash by table_size (numeric). How can I do this.

You don't. Hashes by their very nature don't have an order or sequence.
Therefore the term "sorting a hash" is about as meaningful as trying to sort
the lenght() function. You have to use a different data structure.

Having said that you Question is also Asked Frequently, please see
"perldoc -q sort" for several suggestion about what to do instead.

jue
 
M

Michael Beattie

Do you mean to say you have an array of hash references? that they
themselves have hash references?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top