Well, something is still amiss in the information you're providing. There's no sample dataset to see exactly what's going, so I made some up. The code sorts the data as I would expect, although the print statement makes no use of any of the $field_x variables that you have created.

I've commented out the print portion, since it produces no output relevant to your question. As you can see, the basic sort and printing for the variables you created works as one would expect.

I would assert that you are not using 'use strict' and -w in your script, which will cause you endless grief, the scorn of your ancestors, and a generally low karma value. Try adding them, clean the resulting errors up, and see if that helps a little.
#!/usr/local/bin/perl -w use strict; my @results = (qw(Z|a|b B|c|d H|e|f I|g|h K|i|j M|k|l E|m|n U|o|p P|q| +r Q|s|t A|u|v)); my @sorted = sort {uc($a) cmp uc($b)} @results; foreach my $sorted (@sorted) { my ($field_1, $field_2, $field_3) = split(/\|/,$sorted); print "$field_1, $field_2, $field_3\n"; # my $user = 'arf'; # my $razao_social = 'spot'; # print<<feach; # <tr> # <td bgcolor="#C0C0C0" colspan="2"> # <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> # <a href="/relatorios/$user/$razao_social.data" target="_top +">$razao_social</a> # </font> # </td> # </tr> #feach }

A, u, v B, c, d E, m, n H, e, f I, g, h K, i, j M, k, l P, q, r Q, s, t U, o, p Z, a, b


--Chris

e-mail jcwren

In reply to (jcwren) RE: (3) Sorting search results in PERL by jcwren
in thread Sorting search results in PERL by DaWolf

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.