We're going to need more information. What are you doing with $sortfield. All the code does is keep changing it based on the existance of $IDNumber in %sort_file. Did you snip too much out of your loop? Did you mean to make $sortfield a hash or array of some sort. Your logic is sound up until that last if statement which just keeps changing the value of $sortfield over and over.

Later

P.S. Even if you are missing too much out of your loop, I think I spotted the logic error in your if statement. You assign $total_points when what you really want to assign is $sort_file{$IDNumber} since it is storing the value of $total_points for that hash key. Change it to:

if (exists ($sort_file{$IDNumber} )) { $sortfield = $sort_file{$IDNumber}; } else { $sortfield = ""; }

In reply to Re: sorting an array from two sources by pzbagel
in thread sorting an array from two sources by Anonymous Monk

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.