<?xml version="1.0" encoding="windows-1252"?>
<node id="181965" title="Re: Why didn't this sort?" created="2002-07-15 19:19:14" updated="2005-06-04 00:39:23">
<type id="11">
note</type>
<author id="2329">
stephen</author>
<data>
<field name="doctext">
[perlfunc:sort|sort] doesn't sort a list in-place. Instead, it returns a new sorted list. So:
&lt;code&gt;
foreach (sort @$outputRef) {
   print $_, "\n";
}
&lt;/code&gt;
would print out a sorted list, but printing the contents of $outputRef would still print out an unsorted list.&lt;/p&gt;
&lt;p&gt;
If you need to save the sorted list for some reason, use an assignment:
&lt;code&gt;
@sorted = sort @$outputRef;
&lt;/code&gt;
 
&lt;p&gt;
stephen
&lt;/p&gt;
&lt;b&gt;Note:&lt;/b&gt; Code untested, my Perlboxen are still in pieces...</field>
<field name="root_node">
181957</field>
<field name="parent_node">
181957</field>
</data>
</node>
