A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: using sortOn on Arrays [ASCENDING, DESCENDING]

  1. #1
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508

    using sortOn on Arrays [ASCENDING, DESCENDING]

    how do I get the sortOn function for an Array to support BOTH the NUMERIC and ASCENDING sort orders? DESCENDING seems to be the default or something.

    I have 5 fields, all NUMERIC and I want to sort the first by DESCENDING, 2nd field is ASCENDING, 3rd field DESCENDING, 4th field DESCENDING, 5th field ASCENDING.....how do I achieve this?

    this is for a league standings list, so wins is DESCENDING, losses ASCENDING, ties DESCENDING, points scored is DESCENDING, and points scored against is ASCENDING.....just to give you an idea.

  2. #2
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    I'm sure someone has run into this? sortOn is very useful and saved me a lot of time, but I need to tweak it!

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    In the Array livedoc for sortOn:
    To pass multiple flags, separate them with the bitwise OR (|) operator:
    Code:
      my_array.sortOn(someFieldName, Array.DESCENDING | Array.NUMERIC);

  4. #4
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    is ASCENDING the default because it's not in the list? I need that...thx!

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I've just done an experiment that shows that, yes, ascending is the default.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center