Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8836523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:30:57+00:00 2026-06-14T09:30:57+00:00

using Flash Builder 4.6 i want to sort an arrayCollection. the array has 2

  • 0

using Flash Builder 4.6 i want to sort an arrayCollection. the array has 2 properties status, and help_id. I want to sort the array to have all “open” statuses at the top, than all the “read”, than “onsite”, than “complete”, and so on. i made a function that does this but i want all the items with the same status to than be sorted by the help_id property highest first low est last.

this is my code to sort the statuses.

    [Bindable]protected var myHelp:ArrayCollection = new ArrayCollection();

Sort Function:

    function sortFunction(a:Object, b:Object, array:Array = null):int
                {

                    var status:Array = ["open", "read", "onsite","complete", "reopen", "closed"];
                    var aStatus:Number = status.indexOf(a.status);
                    var bStatus:Number = status.indexOf(b.status);
                    if(aStatus == -1 || bStatus == -1)
                        throw new Error("Invalid value for criticality ");
                    if(aStatus == bStatus)
                        return 0;
                    if(aStatus > bStatus)
                        return 1;
                    return -1;
                }
                var sort:Sort = new Sort();
                sort.compareFunction = sortFunction;
                myHelp.sort = sort;
                myHelp.refresh();

any Help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:30:58+00:00Added an answer on June 14, 2026 at 9:30 am

    instead of looking for string index in an array, why not use ints for both. In your code, you could reference constants like StatusType.OPEN etc… then your code could look like:

    var sort:Sort = new Sort();
    sort.fields = [new SortField("status", true, true), new SortField("help_id", true, true)];
    myHelp.sort = sort;
    myHelp.refresh();
    

    This would sort by status then help_id at the same time. Then when you need to display the status to a user in GUI, convert the int to a String human readable value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Flash Builder 4 Beta 2. I have it connecting to a PHP
I am using Flash builder 4 (SDK3.5) to create my flex program. I want
I have some rich text created using the flex (flash builder 4) rich text
i just started using Flash builder 4 and i have a problem. As it
I'm using Flash Builder 4.5. In an .mxml file, if you want to use
I have been using Flash Builder to build my flex software and I am
I'm using Flash Builder 4.6 and in one of my ActionScript projects, I have
I am using Adobe Flash Builder 4 Premium. I have a mx:DataGrid and a
i'm using an Eclipse based editor (Flash Builder) to write my code. i want
I am using RemoteObjects to call ZendAMF PHP from Flex/Flash Builder 4.6. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.