Randomizing the Elements of an Array : Sort « Array « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » Array » Sort 
Randomizing the Elements of an Array
 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        function randomSort(elementA:Object, elementB:Object):Number {
            return Math.random(  ) .5
        
        
        var numbers:Array = new Array(  );
        for(var i:int=0;i<20;i++) {
            numbers[i= i;
        }
        numbers.sort(randomSort);
        for(var i:int=0;i<numbers.length;i++) {
            trace(numbers[i]);
        }
        
    }
  }
}

        
Related examples in the same category
1. Sorting Arrays
2. Sorting Numerically: Array.NUMERIC
3. Sorting in Descending Order
4. Sorting Regardless of Case
5. A case-insensitive sort using the Array.CASEINSENSITIVE constant
6. Sorting and Testing for Unique Values
7. Getting Sorted Indices
8. Sorting with Multiple Flags
9. Sorting with Custom Algorithms
10. Sort the array's values first according to the type of value and then alphabetically
11. Sort an array in descending order using the Array.DESCENDING constant:
12. sort( ) method runs a case-sensitive sort by default
13. Use the Array.CASEINSENSITIVE constant to run a case-insensitive sort:
14. When you sort an array of numbers, the values are sorted according to the ASCII equivalents of the digits
15. Use the Array.NUMERIC constant with the sort( ) method to sort an array of numbers numerically
16. Sort the array only if it contains unique elements: Array.UNIQUESORT
17. Get the sorted order of an array's elements without changing the original array: Array.RETURNINDEXEDARRAY
18. Combine the combine the constants using the bitwise OR operator (|)
19. Reverse the order of the elements in an array
20. Call the sort( ) method passing the bandNameSort compare function:
21. Getting the Minimum or Maximum Element
w__w___w.j_a_va_2s.__c__o__m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.