Sorting an array of numbers with loops

Hi, i'm looking for a way to sort an array or numbers with loops.
my array looks like this. int[] numbers = {5,2,7,9,1}
i know how to use the "sort" method and i want to do it without the sort method, but i am not very clear on the logic behind it.
by the end it should look like this, {1,2,5,7,9}
i know 2 loops are used, can you please give me a logic to work with.
i have started the loops but what to do inside???
int temp;
for (int i=0; i<numbers.length; i++){
for (int j=1; j<numbers; j++){
if (numbers<numbers[j])
temp = numbers[i];
Any suggestions i will be thankful for.
thank you.

fly wrote:
no not really a homework question.. i want to improve my logic because it is very poor at the moment.. but i'm sure someone knows how to sort an array with loops only.Yes, we do know how to do it, I once wrote a heapsort in assembly code, as a real work project. But you rarely get a project like that the good ones were all done years ago.
All the algorithms I suggested you look at use loops. the simplest and slowest is the bubble sort. This one runs by comparing values and swapping their locations, the wikipedia article http://en.wikipedia.org/wiki/Bubble_sort has the algorithm.

Similar Messages

  • Using .sort() to sort an array of numbers NOT as strings

    Hi,
    is there a function or simple way to sort an array of numbers in order of their values and not as strings? E.g, have 100 come AFTER 9; (9, 100) not (100, 9).
    Thanks.

    use the ARRAY.numeric parameter.
    (and you can always use a custom sort function parameter for more customized sorts.)

  • How to create a list/array off numbers with boolean attributes

    Hi,
         Maybe the title doesn't explain this too well but what I'm trying to do I'd imagine should be straight forward, I just don't know how!
    I want an array of numbers to be entered by a user, and for each of these numbers I wish to have a boolean, (it will select later what action is performed on that number)
    The array size can vary
    e.g.
    element       Numeric Value              Boolean
    0                       5                             True
    1                       20                           True
    2                       -5                            False
    3                       10                           True
    n                       100                         False
    I don't see any list with numeric and boolean, maybe I just haven't spotted it or do I have to make it somehow?
    Any suggestions please?
    Thanks!
     p.s. if anyone else is using Opera Browser to post here, hitting enter work properly for ye when entering text? For me it causes the cursor to go up one line instead of down! Drives me nuts! It only happens with this NI forum
    Solved!
    Go to Solution.

    Hi thanks for the reply, 
                              It not really what I'm looking for though. 
    I require is a control that inputs both numeric and boolean,  as in the example I mentioned. I guess I'm looking for a cluster really but I thought there may be something more straight forward.
    From the example I gave  
    Element 0 of this array has been entered as a x, and the boolean True was entered (so I perform a "test" A on value x)
    Element 1 of this array has been entered as a y, and the boolean True was entered (so I perform a "test" A on value y)
    Element 2 of this array has been entered as a z, and the boolean False was entered (so I perform a "test" B on value z)
    I could also use a 2d array were I enter another numeric value (0/1 for False/True) but I'm not sure I can limit this column only to accept 0 or zero and the first row any number.
    I was hoping there would be some easier way to do this

  • Sorting and formatting in Numbers with iPad 2

    I am going to send feedback to Apple about this, but I wanted to let the community help, if I am incorrect and these things are actually possible.
    1. I can only sort by one column. I want to be able to create a sort priority. For example, I want to sort four columns first by date, then by person's name, then by $ amount. Not possible on mobile Numbers.
    2. I want to choose to sort only specific columns. I have a formula set up in column E that sums the cells to the left in columns C and D. My formulas break every time I sort.
    3. When I copy and paste from one Numbers spreadsheet into another, the formatting from the copied sheet gets put into the pasted sheet. I want to be able to "paste format" like you can in Excel. A sort-of workaround for this is to select the cell that has the correct format (this cell has to be directly above the cells that have the wrong formatting), pull the blue select box down the column to include the cells that have the wrong formatting, click the paintbrush at the top right corner, then choose whatever formatting you need--the format that is shown as selected will be the format of the first-selected cell. You have to do this for every individual column, however. And my columns are very long -- hundreds of cells long (I'm keeping a year's worth of data).
    Am I correct in that if I buy a Mac computer and Numbers for the computer, I would be able to do these edits on the Mac, and then have them show up on my iPad when it synchs with iCloud? I can't buy Numbers for a PC, can I? Being tied to a computer isn't what I want--I wanted to be able to do everything on my mobile device.
    Thanks!

    for #1: numbers does what is called a "stable" sort. Meaning that the previous sort order is preserved. i.e. do your sort in reverse order. Amount, then name, then date. Just did it with sample data and it was perfect. It keeps them in the original order, so if there is a match in name after you sort, you should see the amount still in the proper order.
    #2: What in your formula isnt working? I just made a formula that did math on the columns to the left, sorted and it worked. Sorted by static data columns and the formula column. I know it was broken originally, years ago, but it seems to be working correctly now, at least in my quick test. You might have an issue if you are using formulas that refer to data on other rows or tables.
    #3: yeah formatting can be a pain. But it is easier to do in the desktop program. No, you cannot get it for windows, sorry. If the formatting the only thing you need to do on the desktop side, then i dont see much tying you to it. I do 90% or more on the ipad and iphone now.
    Jason

  • I need to sort an array of strings based on the number in each string.

    Basically, I have a directory of files that all have the same name but each with a different number on the end.
    example: image 1.jpg, image 2.jpg, etc.
    When I use the List Directory function that returns an array of strings containing the file names in the directory, they don't come out in a 1, 2, 3, order like they appear in the directory. It sorts them character by character so that they come out like: 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22 etc.
    Is there a simple way of sorting this array of strings with the file names (as above) so that they are in numerical order?

    It's a while since this thread was started, but I am sure others will have use for this so here goes:
    The in-built array sort function sorts the strings the same way DOS and Windows do. Microsoft has fixed this in the Explorer that comes with XP, however the rest of the OS(s) still sorts the old way.
    The attached "AlphaLogical String Array Sort" VIs will sort strings arrays the same way as the new XP Explorer. There are three different implementations of the sorting, one based on the Insertion sort algorithm, a Quick Sort based on recursive calls (the most elegant way, but unfortunately LabVIEW has too much overhead when doing recursive calls so this is actually a very slow alternative) and finally the fastest; a stack based Quick Sort. There is also a test VI that will show you how the different implementations perform.
    I had not used recursive calls in LV much until I made the attached quick sort and was a bit disappointed by the fact that it is so slow, but it's a good learning example...The ability to do recursive calls this way was introduced in LV7 I believe...There is an example here on the zone that shows how you can calulate a factorial by using recursive calls, however - unlike for the quick sort (normally) - recursive calls are actually not the optimal solution for that calculation.
    Message Edited by Mads on 09-13-2005 02:30 AM
    MTO
    Attachments:
    AlphaLogical Sorting.zip ‏142 KB

  • Help Sorting array of strings with numbers in them

    Hello I need to sort an array of Strings of numbers. The order is not what I want it to be. instead of 1, 5, 20 it will go 1, 20, 5.
    I did a google search for this and found some code that could fix this. The only problem is I tried using it as a method in my program and am getting a compile-time error that I'm not sure how to fix.
    C:\Documents and Settings\Owner\Desktop\stringcompare.java:18: '(' or '[' expected
                new Comparator<String>()
                                    ^I'm not sure what to do here. Any help would appreciated.

    import java.io.*;
    class MyProgram{
    //This is my old bubble sort method which screws up with numbers
    public static String[] sort( String[] points)
              boolean keepGoing = true;
              while(keepGoing == true){
                   keepGoing = false;
                   for(int i = 0; i < points.length - 1; i ++)
                        if(points.compareToIgnoreCase(points[i + 1]) < 0)
                             String temp = points[i];
                             points[i] = points[i + 1];
                             points[i + 1] = temp;
                             keepGoing = true;
              return points;
    //This method reads a pre-existing text file
    public static String[] readPoints() throws IOException
              FileReader file = new FileReader("points.txt");     
              BufferedReader in = new BufferedReader(file);
              String temp;                
              String[] list = new String[100];     
              int i = 0;
              while (i < list.length)                    
                   temp = in.readLine();
                   if (temp != null)
                        list[i] = temp;                    
                   else
                        list[i] = " ";
                   i++;
              in.close();                              
              return list;
    //rewrites file after being sorted
         public static void savePoints(String[] points) throws IOException
              FileWriter file = new FileWriter("points.txt");
              BufferedWriter out = new BufferedWriter(file);
              int i = 0;
              while (i < points.length)          // while the end of file is not reached
                   out.write(points[i]) ;
                   out.newLine();
                   i++;
              out.flush();
              out.close();
    public static void main(String[]args) throws Exception{
    String[]points = new String [100];
    points = readPoints();
    points = sort(points);
    savePoints(points);
    for(int i = 0; i < points.length - 1; i++)
    System.out.println(points[i]);
    The problem is that it doesn't sort as I would like it and I'm not sure how to get the comparator to work properly.
    Edited by: myol on May 31, 2008 4:21 PM
    Edited by: myol on May 31, 2008 4:23 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Sorting array of numbers

    I have an multiple arrays of numbers 1-10 in different orders. I want to sort them in ascending order.
    example
    for(int pass=0; pass < sizeofarray; pass++){
        for(int t=0; t < sizeofarray; t++){
            if(array[t] > array[t+1]){
                hold=array[t];
                array[t] = array[t+1];
                array[t+1] = hold;
    }This loops through 10 times no matter how the array is originally sorted. How do I decrease the number of times this cycles if the array is pre-sorted?
    example arrays {10,9,8,7,6,5,4,3,2,1} need to go 10 times
    {1,2,3,4,5,6,7,8,9,10} only needs to check it once.
    Help, please only loops, no array.sort. This is a homework assignment.

    Quicksort while effective, is not what I needed. A modified bubble sort is what I wanted. Thanks to all who posted. I found the logic I was able to modify for my needs at
    http://www.autoobjects.com/Home/Teaching/CmpE_126/CmpE_126_Lectures/Sortings/sortings.html#Bubble_Sort
    here's basically what it did (in C++):
        Improved Bubble Sort                                                                                                        */
    void BubbleSort( UserData x[ ], int siz ){
            int i, j, switched;
            /* outer loop controls the number of pass */
            for( i = 0, switched = true; i < siz - 1 && switched == true; i++ ){
                    /* initially no interchanges have been made on this pass */
                    /* inner loop controls each individual pass */
                    for( j = siz - 1, switched = false; j > i; j-- ){
                            if( getKey( x[ j ] ) > getKey( x[ j - 1 ] )){  /* an interchange becomes required */
                                    switched = true;
                                    Swap( x[ j ], x[ j - 1 ] );
                            }        /* inner loop */
                    }       /* outer loop */
            return;
            }Thanks to jbish who had the most useful answer for my needs.

  • Need help with ouput of a list or array of numbers input from user

    I'm only a few weeks into learning java, so this may seem simple to some, but...
    I am trying to write a program that will receive numbers from a user,
    and then list, add, average those numbers. I've got the program to
    work except for listing the numbers that were input.
    Can someone help guide me????
    i've left the code I've tried in as comments.
    Enter an integer value, the program exits if the input is 0:
    20
    Enter an integer value, the program exits if the input is 0:
    40
    Enter an integer value, the program exits if the input is 0:
    60
    Enter an integer value, the program exits if the input is 0:
    80
    Enter an integer value, the program exits if the input is 0:
    0
    Total numbers entered: 4
    The array of numbers is: 0 0 0 0
    The sum is 200
    The average is 50
    The maximum number is 0
    The minimum is 0
    Here is my code:
    * Title:        Reads integers and finds the total, average, maximum of the input values
    * Description:
    * Copyright:    Copyright (c) 2002
    * Company:      Duke Court.
    * @author Mary Davenport
    * @version 1.0
    public class part3page6
      public static void main(String[] args)
      int data = 0;
      int sum = 0;
      int countnum = -1;
      int maximum = 0;
      int minimum = 0;
      int average = (countnum - 1);
      do
          System.out.println("Enter an integer value, " +
            " the program exits if the input is 0:  ");
          data = MyInput.readInt();
          sum += data;
          countnum++;
        } while (data != 0);
          //in order to figure the max & the min it appears that the
        //program will need to utilize arrays to store the individual numbers
        //that are input from the user.
        //create an array of the input data
        int[] number = new int[countnum];
        //creat a list of the input data
        int []myList = {data};
        //lists how many numbers entered
        System.out.println("Total numbers entered:  " + number.length);
        //list array of numbers -- this is giving me [I@3179c3,
        //instead of 20, 40, 60, 80 when I use "new int[countnum]"
    //     System.out.print("The array of numbers is: "
    //      + new int[countnum]);
        //list array of numbers:  this is giving me " 0 0 0 0 "
           //instead of 20, 40, 60, 80  with the following for statement
           // (number[i] + " ")
        System.out.print("The array of numbers is: ");
          for(int i=0; i<number.length; i++)
            System.out.print(number[i] + "  ");
      //list mylist of numbers from input, 20, 40, 60, 80
      //output is The list of numbers is: [I@3179c3
    //  System.out.print("The list of numbers is: " + myList);
        System.out.println();
        System.out.println("The sum is " +  sum);
        average = sum/countnum;
        System.out.println("The average is " + average);
        System.out.println("The maximum number is " +  maximum);
        System.out.println("The minimum is " +  minimum);

    When you input the data you need to save it to the array. Currently you are not saving the value you are just adding it
    ArrayList nums = new ArrayList();
       do
           System.out.println("Enter an integer value, " +
             " the program exits if the input is 0:  ");
           data = MyInput.readInt();
    nums.add(new Integer(data));
           sum += data;
           countnum++;
         } while (data != 0);

  • Populating an array of objects with a loop. Noob PHP question.

    Hey guys,
       You are all such a great help! Here is another one for you, the simple code below should create an array of pizza objects (and it does) then display each object in order. However... for some reason each object in the array seems to inherit the properties of whatever the last object entered was.
    This code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <?php
    class pizza{
              public $price;
              public $description;
              public $name;
    $menu2=fopen("pizzaMenu2.txt","r") or exit("System Error!");
    $pizzas = array();
    $arraypos=0;
    //This loop does all of the READING and populating of variables
    while(!feof($menu2))
                //First get the array position
                                  $arraypos = (int)fgets($menu2);
              //Then Put in Title in title2 array
                                  $pizzas[$arraypos2] = new pizza(0,0,0);
                                  $pizzas[$arraypos2]->title = fgets($menu2);
                                  $pizzas[$arraypos2]->description = fgets($menu2);
                                  $pizzas[$arraypos2]->price = fgets($menu2);
      } //End of reading loop
    //begin writing data
    $arraypos=1;
    while ($arraypos <=3){
              echo "the array is in position: ".$arraypos;
              echo "<br />";
              echo $pizzas[$arraypos2]->title;
              echo "<br />";
              echo $pizzas[$arraypos2]->description;
              echo "<br />";
              echo $pizzas[$arraypos2]->price;
              echo "<br />";
              $arraypos++;
    }//end of writing data loop
    fclose($menu2);
    ?>
    <body>
    </body>
    </html>
    returns this:
    the array is in position: 1
    Test Pizza Two
    The same as one with an extra one, yum!
    22.99
    the array is in position: 2
    Test Pizza Two
    The same as one with an extra one, yum!
    22.99
    the array is in position: 3
    Test Pizza Two
    The same as one with an extra one, yum!
    22.99
    when it should return this:
    the array is in position: 1
    Test pizza One
    Loaded with all that test pizza goodness! Lots and lots of ones 1111!
    11.99
    the array is in position: 2
    Test Pizza Two
    The same as one with an extra one, yum!
    22.99
    the array is in position: 3
    Test Threeza!
    Do you see what I did there? I added a three to pizza, hahaha, I am so punny.
    33.33
    using the following text file pizzaMenu2.txt:
    1
    Test pizza One
    Loaded with all that test pizza goodness! Lots and lots of ones 1111!
    11.99
    3
    Test Threeza!
    Do you see what I did there? I added a three to pizza, hahaha, I am so punny.
    33.33
    2
    Test Pizza Two
    The same as one with an extra one, yum!
    22.99
    Now, I have done line by line testing and shown that the values are being entered into the proper objects in the proper array, but whatever goes in last overwrites all of the other objects, so in the end I have 3 objects in my array that are all the same. I am not sure what I am missing here.

    Christ-Guard wrote:
    Thanks! I majored in computer science
    That helps enormously.
    Christ-Guard wrote:
    Also, I have never worked a CS job before and I've been out of school for 8 years, so I am better at remembering "This should work" then I am at "This is how I write this code".
    If you have a good idea something should work, based on theory, then that's half the battle.
    Its having no knowledge if something will work or not when it becomes a problem.

  • Sort an array of Application Class with respect to property

    class MyClass
    property string myProgram;
    property string myType;
    property string Description;
    end-class;
    Local array of MyClass &myProgArray;
    &myProgArray.Sort("D");
    I want to sort the Array in descending Order with respect to "myType".
    How to provide "myType" parameter to sort method ?
    Edited by: Mohsin on Oct 11, 2012 3:28 PM

    If you add myType to the array then you can sort on that, assuming you have different values for myType.
    According to PeopleBooks (8.51), API documentation;
    Sort(order)
    Note. This method works with arrays that have only one or two dimensions. You receive a runtime error if you try to use this method with an array that has more than two dimensions.

  • Sort an array with two fields

    i have an array with three fields: id, name and date.
    i want to sort it by name first and then date.
    the size of my array could be as large as 1 million.
    what could be the most efficient way to do so?
    tia!

    It's very inefficient to sort an array on "the fly".
    In that case at least use a linked list so you don't
    have to move all elements after the insertion point to
    make room for a new insert. But it's much better to
    sort afterwards when all elements are in the array.Use a TreeSet. A linked list will be slower than a TreeSet, I suspect.
    I believe that with a TreeSet, insertions will be somewhat slower (O(logN) vs O(c)), but the subsequent sorting of a linked list will be, what, at least O(NlogN) and possibly O(N^2)? And when you're inserting the first elements into the TreeSet, it should be closer to O(c) anyway, whereas the after-the-fact sorting of a LinkedList wouldn't have an advantage like that.
    Then if necessary extract an array out of the TreeSet when you're done creating/inserting elements.
    But really, use a database.

  • Convert "1D array of dynamic data" to "Dynamic data" after auto-indexing with loop

    Hi -
    I have a question about how exaclty auto-indexing works with the Dynamic Data type when exiting a while loop. I'd like to use the DAQ assistant to record data through an analog input (on the MyDAQ) and then replay that data through an analog output. This works fine if I use the DAQ Assistant to record data for a set amount of time:
    However, I run into trouble when I try to use a While loop with a stop button to record data for an arbitrary amount of time. I set the dynamic data tunnel out of the While loop to "Indexing", but then when it exits the loop, it becomes "1-D Array of Dynamic Data" instead of just "Dynamic Data", and get a broken wire when I try to connect it to the input of the DAQ Assistant. I've also tried converting the dynamic data to Array and Waveform data types inside the loop, but have the same issue (they become 2D Array and 2D Array of Waveform respectively when leaving the loop). Try as I might using blocks like Convert to/from Dynamic Data Type, or Array Subset, I'm unable to get them back down to just Dynamic Data or Waveform, which will be accepted by the DAQ Assistant:
    One other small note - I'm not sure if using the "Build Array" function with a shift register accomplishes exactly the same thing as just auto-indexing an array out of the loop - so I've tried both, but still have the broken wire issue.
    I'm assuming this is just a simple issue of using the right block to convert "1D Array of [Something]" to just plain [Something]. Any help appreciated.
    Attachments:
    PWM_FlatSequence.vi ‏101 KB
    PWM_FlatSequence_While.vi ‏129 KB

    I have been facing problem for all temperature values placing the Write to Measurement File outside the Loop. 
    In Error message it says" Source: 1D array of dynamic data and Sink: Dynamic data".
    Is there any means of convering 1D array of dynamic data to dynamic data?
    I would highly appreciate any help.
    Attachments:
    Temperature Logger.vi ‏110 KB

  • Sort algorithm: how can I sort two arrays according to one

    I have two parallel arrays, similar to this:
    var array1 = [4, 3, 1, 5, 2];
    var array2 = ["four", "three", "one", "five", "two"];
    I want to sort the first array, and have the second array follow the same sort as the first. Any advice for a good algorithm would be appreciated.
    Rick Quatro

    Hi Rick,
    frameexpert wrote:
    Technically, there was no correct answer because the problem could be solved in multiple ways,
    I don't think you're right about not marking the question as correct just because there are multiple ways of solving it.
    People search the forums for solutions and threads that are not marked as correct are somewhat relegated.
    It wouldn't hurt to make bduffy232's day or even mark your own solution as correct which is more the less the same as the one on the link from KuddRoww and more the less the way I would have done it but see the difference in the results in the table at the bottom of this post.
    I actually think that technically there can be multiple correct answers even though you can only  one can be marked.
    One other small point if you use the advance editor on the forum you can have you code formatted makes it much easier to read.
    Anyway here's my half pence worth on the scripting front.
    Your question was how to sort one array according to another, which I understand to mean that you want the originals arrays reordered
    Yours and bduffy232's scripts do that properly the others don't. Jongware's first script is easy to fix up this problem by adding to the end of his script.
    for (i = 0; i<Math.min(array1.length, array2.length); i++)
    array1[i] = array3[i][0];
    array2[i] = array3[i][1];
    alert(array1+"\r"+array2)
    Now in order of appearance
    Jongware said:
    .. I wonder why this does not work .. Perhaps my logic is flawed?
    Hi Jongware
    I tried your  (2nd) script twice and on both occurrences it crashed my ESTK
    From what I  understand (not said with much confidence) the flaw in your logic is you are passing your arrays values to be sorted array1[?] and array2[?+1] to the sort function as 'a' and 'b' but and then refer to the array array1[a].
    So let's examine a bit of the code
    var array1 = [4, 3, 1, 5, 2];
    array3.sort (function(a,b) {
    var swap, diff = array1[a] - array1[b];
    When run this is the equivalent of saying (for the first run of the sort loop)
    diff = array1[4] - array1[3]
    i.e.     diff = 2 - 5
    i.e.     diff = -3
    What you wanted to do was
    diff = a - b
            = 4 -3
    That's the way I see it.
    Hi Marc
    Change the first two lines of your first script to:
    var array1 = [40, 7, 1, 5, 2];
    var array2 = ["forty", "seven", "one", "five", "two"];
    Then run the script
    Now for my offering.
    The fancy script
    This script is not limited to a specific number of arrays.
    after creating the arrays one creates an array of the arrays, specifies the number of the array that one wants to sort by and calls the function.
    like this:
    sortArraysInSync([a1,a2,a3,a4,a5], 1);
    The arrays a1, a2, a3, ..... will get sorted according to the numeric or alphabetical order of the array specified in the 2nd parameter.
    One could easily (I think) change the sort function to first sort by array x and then by array y etc.
    // Advanced Sort Variable Numbers of  Arrays in Sync Script by Trevor
    // http://forums.adobe.com/thread/1062126?tstart=0
    var   a1 = [2, 5, 10, 7, 100, 5, .5, 0]
            a2 = ['two', 'five', 'ten', 'seven', 'one hundred', 'five', 'one half', 'zero'],
            a3 = [ 'deux', 'cinq', 'dix', 'sept', 'cent', 'cinq', 'un demi', 'zéro' ],
            a4 = [ 'twee', 'vijf', 'tien', 'zeven', 'honderd', 'vijf', 'helft', 'nul' ],
            a5 = [ 'tsvey ', 'finef', 'tzien', 'zibn', 'eyn honderd', 'finef', 'eyn halb', 'nul' ];
    alert("\tIndividual Arrays Before Sort\r"+a1+"\r"+a2+"\r"+a3+"\r"+a4+"\r"+a5);
    sortArraysInSync([a1,a2,a3,a4,a5], 1);
    alert("\tIndividual Arrays After Sort\r"+a1+"\r"+a2+"\r"+a3+"\r"+a4+"\r"+a5);
    function sortArraysInSync (myArrays, s /* number or the array to sort by (starting from 1) */)
        arr = []; var l1 = ll1 = myArrays[0].length, i = ll2 = myArrays.length;
        s--;
        while(l1--)
                arr[l1]={}           
                i = myArrays.length;
                while(i--) eval("arr["+l1+"].key"+i+" = myArrays[i][l1]");
        arr.sort(mySort);
        while (ll1--) for (i=0; i<myArrays.length;i++) eval ("myArrays[i][ll1] = arr[ll1].key"+i);
        alert("\tFunction Array After Sort\r"+myArrays.join("\r"))
    function mySort(a, b)
            if (eval("isNumber(a.key"+s+") || isNumber(b.key"+s+")")) return eval("a.key"+s+"- b.key"+s+"");
            else if (eval("a.key"+s+".toLowerCase() > b.key"+s+".toLowerCase()")) return 1 else return -1;
    function isNumber(n) {return !isNaN(parseFloat(n)) && isFinite(n)}; // isNumber function from http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric/1830844#1830844
    For the simple 2 array sort I would have done as I said much the same as your one:
    // Simple Sort Arrays in Sync Script by Trevor
    // http://forums.adobe.com/thread/1062126?tstart=0
    var   a1 = ['two', 'five', 'ten', 'seven', 'one hundred', 'five', 'one half', 'zero'],
            a2 = [2, 5, 10, 7, 100, 5, .5, 0]
    alert("Individual Arrays Before Sort\r"+a1+"\r"+a2);
    sortArraysInSync(a1,a2);
    alert("Individual Arrays After Sort\r"+a1+"\r"+a2);
    function sortArraysInSync (x, y)
        var arr = [], l1 = l2 = Math.min(y.length, x.length);
        while (l1--) arr.push({name: x[l1], number: y[l1]});
        arr.sort(function(a, b) { return a.number - b.number; });
        while (l2--)
            x[l2] = arr[l2].name;
            y[l2] = arr[l2].number;
    I did a speed test by putting 2 3000 item arrays into my, your dbuffies and Jongware script and timing them.
    These were the results.
    Test done with alerts removed with program set to real time priority and alerts removed.
    These were the arrays and timing method
    var   a1 = ['zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two', 'zero', 'one half', 'five', 'one hundred', 'seven', 'ten', 'five', 'two'],
            a2 = [, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2, 0, 0.5, 5, 100, 7, 10, 5, 2];
    sdate = new Date();
    startTime = sdate.getTime();
    sortArraysInSync([a1,a2],2); // each scipt to its own.
    edate = new Date();
    endTime = edate.getTime();
    totalTime = (endTime-startTime)/1000;
    alert("Individual Arrays After Sort\r"+totalTime+"\r"+a1+"\r"+a2);
    Script
    Seconds taken to sort 2 Arrays 3000 items each
    Comments
    Trevor's Simple Script
    1.3
    Rick's (Frameexpert) Script
    12.3
    Trevor's Fancy Script
    33
    Bduffy's Script
    68
    Jongware's Script
    Crashed, don't know why?
    Don't forget to pick the correct answer.
    My 'fancy' script is slowed down considerably because of thoses evil  evals. Does anyone have a solution for this?
    Regards
    Trevor

  • Sorting an array of integers into ascending order

    Today I decided to blow the cobwebs off my old laptop and see what I could remember from my Java days.
    As a task for myself to see what I could remember, I decided to try and write a program that does the following:
    - Declares an array of 4 integers
    - Sorts the array into ascending order, from lowest to highest.
    - Prints on screen the sorted array.
    After an hour or so I finally cracked it, and ended up with a working program. Here she is:
    public class Sorting_arrays_1
        public static void main()
           int [] array = {4,3,7,1};
           //A variable used to help with swopping values
           int temporary;
              //finds the smallest number out of elements 0, 1, 2, and 3 of the array, then moves it to position 0
              for (int count = 0; count<array.length;count++)
                int smallestNumber = array[0];
                if (array[count] < smallestNumber)
                    smallestNumber = array[count];
                    temporary = array[0];
                    array[0]=array[count];
                    array[count]=temporary;
             //finds the smallest number out of elements 1, 2, and 3 of the array, then moves it to position 1
             for (int count = 1; count<array.length;count++)
                int smallestNumber = array[1];
                if (array[count] < smallestNumber)
                    smallestNumber = array[count];
                    temporary = array[1];
                    array[1]=array[count];
                    array[count]=temporary;        
              //finds the smallest number out of elements 2 and 3 of the array, then moves it to position 2
              for (int count = 2; count<array.length;count++)
                int smallestNumber=array[2];
                if (array[count] < smallestNumber)
                    smallestNumber = array[count];
                    temporary = array[2];
                    array[2]=array[count];
                    array[count]=temporary;     
             //prints the array in ascending order
             for (int count=0; count<array.length;count++)
                 System.out.print(array[count] + " ");
    }Could this code be simplified though? Maybe with a for loop?
    I mean, it does the job, but it looks so clumbsy and inefficient... Imagine how much code I would need if I wanted to sort 1000 numbers..

    Use bubble sort if u want a quick fix
    public static void bubbleSort(int [] a)
    for(int i=0; i<a.length-1; i++)
         for(int j=0; j<a.length-1-i; j++)
              if(a[j]>a[j+1])
                   int temp = a[j];
                   a[j]=a[j+1];
                   a[j+1]=temp;
    Or use Merge sort if u want better run time... ie.(N log N)

  • Finding Mode of an array of numbers.

    I'm having troubles with finding the mode of an array of numbers.
    When the mode is in the middle of the set of numbers, it works, but when it is at the end, it doesnt.
    For example..
    if i had the numbers ...
    2,3,3,4,5,6,6,6 in an array, it would tell me that the mode is 3.
    if i had the numbers...
    2,4,5,5,5,6 in an array, it would tell me that the mode is 5.
    So the first set of numbers, the mode is incorrect, but the second set of numbers is correct.
    The following is my code...
    public static int getMode(int[] list)
    int mode = 0;
    int elements = 0;
    int tempMode = list[0];
    int temp = 1;
    for(int x = 1; x < list.length; x++)
    if(list[x-1] == list[x])
    temp++;
    }else{
    if(temp > elements)
    System.out.println("entered");
    tempMode = list[x-1];
    elements = temp;
    temp = 1;
    }else{
    temp = 1;
    mode = tempMode;
    return mode;
    }

    You need to add another test at the end of the loop:
        public static int getMode(int[] list)
            int mode = 0;
            int elements = 0;
            int tempMode = list[0];
            int temp = 1;
            int x;
            for (x = 1; x < list.length; x++)
                if (list[x - 1] == list[x])
                    temp++;
                else
                    if (temp > elements)
                        tempMode = list[x - 1];
                        elements = temp;
                        temp = 1;
                    else
                        temp = 1;
            if (temp > elements)
                tempMode = list[x - 1];
            mode = tempMode;
            return mode;

Maybe you are looking for