I just searched for the word sort in your lengthy code and did not find a match. XML::Simple does not sort the data for you ... you have to sort it yourself:

use XML::Simple; use Data::Dumper; my $xml = XMLin(\*DATA); print Dumper $xml; $xml->{bar} = [ sort @{ $xml->{bar} } ]; print Dumper $xml; __DATA__ <foo> <bar>4</bar> <bar>1</bar> <bar>3</bar> <bar>2</bar> <bar>5</bar> </foo>
I recommend that next time, you trim your code down to the relevant parts, for example, CGI.pm has nothing to do with the problem, so you shouldn't bother posting those parts. Just post the relevant part ... which means you need to copy the script and trim out the stuff you don't need. 8 or 9 times out of 10, you will solve the problem yourself if you do this. :)
Yeah ... like that. :)

UPDATE: now that i can see the spot, try this foreach instead: (untested)

for my $this (sort {$a->{THIS} cmp $b->{THIS} } @{$xml->{policies}}) {
Where you replace THIS with the XML tag you want to sort by.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: XML::Simple Not Sorting by jeffa
in thread XML::Simple Not Sorting by bkiahg

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.