<?xml version="1.0" encoding="windows-1252"?>
<node id="999801" title="Re^2: Multiple Sort on selected column" created="2012-10-18 15:31:13" updated="2012-10-18 15:31:13">
<type id="11">
note</type>
<author id="449608">
thundergnat</author>
<data>
<field name="doctext">
&lt;p&gt;I agree with one small caveat. It might be better to change the cmp_by sub to do a numeric comparison in addition to the string comparison. With just the cmp, 600000 sorts after 55000 but 400000 would sort before. The following will sort numerically largest to smallest then alphabetically.&lt;/p&gt;

&lt;c&gt;
sub cmp_by {
    my $result;	
	for my $term (@_) {
        $result ||= +$b-&gt;{$term} &lt;=&gt; +$a-&gt;{$term} or $a-&gt;{$term} cmp $b-&gt;{$term};
    }
    return $result;
}
&lt;/c&gt;</field>
<field name="root_node">
999789</field>
<field name="parent_node">
999791</field>
</data>
</node>
