1 Reply Latest reply on Feb 19, 2012 7:37 PM by nfallon55

    Sort ArrayCollection or Listbox

    nfallon55

      I have to sort either an ArrayCollection or a Listbox.  I have tried the following ArrayCollection example and it ran without errors but did not sort.

       

      var sort:Sort = new Sort();
      // There is only one sort field, so use a null
      // first parameter.
      var sortfield:SortField = new SortField("null",true);
      sortfield.setStyle("locale","en-US");
      sort.fields = [sortfield];
      myAC.sort = sort;
      myAC.refresh();

       

       

      Is there a way to sort the Listbox contents in ascending order.  The data is just names.  It is the same data that is in the ArrayCollection.

       

      Neil

        • 1. Re: Sort ArrayCollection or Listbox
          nfallon55 Level 1

          I figured it out.  I had to change the code a little.

           

          var sort:Sort = new Sort();
          // There is only one sort field, so use a null 
          // first parameter. 
          var sortfield:SortField = new SortField(null,false);
          // Set the locale style to "en-US" to set the language for the sort.
          sortfield.setStyle("locale","en-US");
          sort.fields = [sortfield];
          myAC.sort = sort;
          myAC.refresh();

           

           

          Neil