JavaScript Reference/Javascript Methods/sort

Материал из Web эксперт
Перейти к: навигация, поиск

"sort()" Example

    
<html>
<body>
<button onclick="var myA = new Array(0,5,3,1,2,4,6); 
                 myA.sort(); 
                 alert(myA);">sort array</button>
</body>
</html>



"sort()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |Array                                                         |
+----------------+--------------------------------------------------------------+



"sort()" Syntax, Parameters and Note

Note:
Sorts the elements in the array alphabetically.
    
Syntax:
    
arrayName.sort()