2 Replies Latest reply on Nov 4, 2006 6:40 AM by Hoiku

    XML > Array problem

    Hoiku
      I want to load data from a XML file to an array:
      then sort descanding.
      XML :
      <test>
      <node>15</node>
      <node>20</node>
      <node>30</node>
      <node>7</node>
      </test>

      code:
      test = new XML();
      test.load("test.xml");
      test.onLoad = function() {
      A = new Array();
      for (i=0; i<this.firstChild.childNodes.length; i++) {
      A.push(this.firstChild.childNodes .firstChild.nodeValue);
      }
      A.sort(Array.DESCENDING | Array.NUMERIC);
      trace("A = "+A);
      //------------
      B = new Array();
      B = [15, 20, 30, 7];
      B.sort(Array.DESCENDING | Array.NUMERIC);
      trace("B = "+B);
      };

      result:
      A = 7,30,20,15
      B = 30,20,15,7

      seems that even I use "Array.NUMERIC", flash still tread the XML data as Srting, instead of a number.
      ( see the different of A and B)

      how could I make it number ? please help.