Javascript Array Sort

One of the most useful array methods is sort().  It will sort your content. The sort() works  much like the qsort() functions in the standard library. This method sort the array element in  place according to lexicographic order. First it convert the array elements to a string and then sorting them lexicographically. This can cause an unexpected result in some cases.

Example of Javascript Array Sort :- 

<html>

<head>

<title> I am working on javascript</title>

<script>

var myarray=[34,45,56,13,90];

myarray.sort();

alert(myarray);

</script>

<body>

<p>  Array is sort in javascript</p>

</body>

</html>

Result of Javascript Array Sort 

13 , 34 , 45 , 56 , 90




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top