Sorting a hahs of hashes

M

Me

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

Gunnar Hjalmarsson

Me said:
I have a hash (of a hashes) that has data like this
table1->table_name
->table_size
table2->table_name
->table_size
.
.
.
table_n->table_name
->table_size


I need to sort the hash by table_size (numeric). How can I do this.

perldoc -q "sort a hash"
 
T

Tore Aursand

Me said:
I have a hash (of a hashes) that has data like this
table1->table_name
->table_size
table2->table_name
->table_size
.
.
.
table_n->table_name
->table_size

Please post the real code. If not, at least provide us with the output
of the hash's structure as reported by the Data::Dumper module.
 
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 your Question is also Asked Frequently, please see
"perldoc -q sort" for several suggestion about what to do instead.

jue
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top