Hi QM,

How about using a hash, with the key being the string item, and the value being an index, which gets incremented each time you find a new string.

Then you can sort numerically on the values of the hash to get the original order.

Is that what you're looking for?

Update:  After rereading your question more carefully, it looks like that doesn't work.  But perhaps if you use a hash where the value corresponding to each string is a hash, within which each key is the number of times "Start" has been found, and the value is the index within that sublist.  You'll know an item isn't in a given sublist, because the corresponding key won't be defined.

For example:

Start # This is sublist #1 Alpha # $p->{'Alpha'}->{'1'} => 1 Beta # $p->{'Beta'}->{'1'} => 2 Start # This is sublist #2 Epsilon # $p->{'Epsilon'}->{'2'} => 1 Zeta # $p->{'Zeta'}->{'2'} => 2 Start # This is sublist #3 Beta # $p->{'Beta'}->{'3'} => 1 Gamma # $p->{'Gamma'}->{'3'} => 2 Zeta # $p->{'Zeta'}->{'3'} => 3 Start # This is sublist #4 Alpha # $p->{'Alpha'}->{'4'} => 1 Gamma # $p->{'Gamma'}->{'4'} => 2 Delta # $p->{'Delta'}->{'4'} => 3 Epsilon # $p->{'Epsilon'}->{'4'} => 4 would give a hash like: $p = { 'Alpha' => { # Note 'Alpha' doesn't appear in sublist #2 or #3 1 => 1, # Alpha is #1 in the 1st sublist 4 => 1, # Alpha is #1 in the 4th sublist }, 'Beta' => { 1 => 2, 3 => 1, }, 'Epsilon' => { 2 => 1, 4 => 4, }, 'Zeta' => { 2 => 2, 3 => 3, }, 'Gamma' => { 3 => 2, 4 => 2, }, 'Delta' => { 4 => 3, }, };

Does something like that help you?


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: Reconstructing List Order From Partial Subsets by liverpole
in thread Reconstructing List Order From Partial Subsets by QM

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.