To yield:my %values = ( "apple" => "1", "pear" => "3", "orange" => "3", "melon" => "2", "grape" => "2");
Kutsu tried to help with the code on his pad. The idea was to use HOA or AOAs and I haven't any experience with those (or references) so I'm kind of lost. What I have to play with isLevel 3: Pear, Orange Level 2: Melon, Grape Level 1: apple
Which works. The problem I am having is trying to figure out how this would work with dynamic data. I'll never know what "levels" exist or how many there are, so using indexes probably won't work properly.my %hash = ( 1 => ["apple"], 2 => ["melon", "grape"], 3 => ["pear", "orange"] ); $hash{1}[1] = "pickle"; print "Level $_\n@{$hash{$_}}\n\n" for reverse sort keys %hash;
In the end, I need to be able to sort and rip parts and pieces of this with ease (like a typical hash). Things to keep in mind are; I need to be able to sort by length of characters in the words, and find specific elements which words start with (or end with) specific characters. Ideally, it'd need to be as maintainable as a hash which I'm sure HOAs and AOAs are capable of.
I'm just new to the multidimensional world and could use some insight.
In reply to Sorting hashes with new value detection by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |