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

  • SEARCH
  • Home
  • 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 6000795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:44:43+00:00 2026-05-23T00:44:43+00:00

I am trying to sort big array using actionscript 3. The problem is that

  • 0

I am trying to sort big array using actionscript 3.

The problem is that i have to use custom sorting function which is painfully slow and leads to flash plugin crash.

Below is a sample code for custom function used to sort array by length of its members:

            private function sortByLength():int {
                var x:int = arguments[0].length;
                var y:int = arguments[1].length;
                if (x > y){
                    return 1;                       
                }else if (x < y){
                    return -1;
                }else{
                    return 0;
                }
             }

Which is called like this:

    var txt:Array = ["abcde","ab","abc","a"];
    txt.sort(sortByLength);

Please advise me how can this be done faster ?

How to change application logic to avoid Flash plugin crashes during sorting ?

  • 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-05-23T00:44:44+00:00Added an answer on May 23, 2026 at 12:44 am

    try to use strong typing whenever possible, here tell your function that you are waiting two strings.

    you could rewrite your function in two way one fastest than the other if you know that all your element are not null:

    function sortByLength(a:String, b:String):int {
        return a.length-b.length // fastest way not comparison
    }
    

    and if you can have null check for it (this one will put null in front of all element):

     function sortByLengthWithNull(a:String, b:String):int {
         if (a==null) return -1
         if (b==null) return 1
         return a.length-b.length
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to sort a multidimensional array in objective-c i know that i can
Trying to sort an array by writing my own sort method using recursion (Pine's
Trying to sort an array in PHP that is being populated from a CSV.
So I've got a solution that contains a few big projects, which I'm trying
I have a weird but big problem. I am trying to let the user
Trying to sort this array of objects according to (1) depth and (2) weight,
I am trying to sort a list using delegates but I am getting a
I'm trying to sort any array with array_multisort() and everything is working great. However,
I am trying to make a sort of progress bar that gets filled, with
I'm having a strange problem, that I've been trying to solve for too long.

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.