- The sort() method is used to sort the items of an array.
- The order of the sorting are either ascending or descending and either alphabetic or numeric.
Code:-
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>sort()</h1>
- <h1>ar = ["G","X","Q","A","Z","B"]</h1>
- <input type="button" onclick="ar_sr();" value="Call Array Sort">
- <script>
- function ar_sr()
- {
- var ar = ["G", "X", "Q", "A", "Z", "B"];
- alert("Actual : " + ar);
- alert("Sorted Array : " + ar.sort());
- }
- </script>
- </body>
- </html>
Sort in Array:- Geniusofstudent
Reviewed by Network security
on
August 06, 2019
Rating:
No comments: