It sounds like you want a Hash of Hashes, that looks something like:
$VAR => { City-Center1=> { Data-items for first combination } City-Center2=> { Data-items for second combination } ... }
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.