<html>
<head>
<title>
Sorting Number Using JavaScript
</title>
<script type="text/JavaScript" language="JavaScript">
Array.prototype.SrtNum = function()
{
return this.sort( function (a,b) { return a-b; } );
}
var arr = [5,9,1,10,8,4,2,7,3];
document.write("Before Sorting :"+arr+"<br />After Sorting :"+arr.SrtNum());
alert(arr=arr.SrtNum());
</script>
<head>
<body>
</body>
</html>
Program Demo
No comments:
Post a Comment