Where the top-level is keyed by the concatenation of the city and center names and a reference to the hash of the data for each city/center combination is the top-level value. Then your center-within-city becomes a simple sort of the top-level keys, and a dereference from the coresponding value.$VAR => { City-Center1=> { Data-items for first combination } City-Center2=> { Data-items for second combination } ... }
In Pseudo-Code (because I haven't run it through the interpreter) --
my %city_center_hash; # Loading the data structure -- while <DATA> { ($variables) = split data line my $this_key = "$o_city|$o_tcenter"; # select an # appropriate # separater $city_center_hash{$this_key} = { data_item1 => variable1, data_item2 => variable2, # ... data_itemN => last_variable, }; } # .... # .... # Retrieve the data from the data-structure foreach $cc_combo (sort keys %city_center_hash) { my ($this_city, $this_center) = split /\|/, $cc_combo; my $these_data = $city_center_hash{$cc_combo}; my $variable_item1 = $these_data -> {data_item1}; # Do something with the names and the first # data variable # etc .... }
----
I Go Back to Sleep, Now.
OGB
In reply to Re: How to sort a non-unique value within unique values
by Old_Gray_Bear
in thread How to sort a non-unique value within unique values
by hmbscully
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |