I'm not quite sure what sorting you are trying to do (you should specify with some examples). But optimally, you will not load XML fragments into your array.
$xmlfile="
<Level1>
<Level2>
<Level2Item VAR1="1" VAR2="2" ... />
<Level2Item VAR1="4" VAR2="5" ... />
<Level2Item VAR1="7" VAR2="8" ... />
</Level2>
</Level1>";
$xml = new SimpleXMLElement($xmlfile);
foreach ($xml->Level2[0] as $result) {
$VAR1Array[] = (int) $result['VAR1'];
$VAR2Array[] = (int) $result['VAR2'];
}
, sort() , (.. sort($array); , $array . int like php, , . array_push , php $var[] .