JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

HOW TO SORT ELEMENTS OF AN ARRY SEQUENTIALLY USING THE sort() METHOD

The array sort() method in javascript sorts the elements in an array sequentially. String elements are sorted alphabetically whilst integer and floating-point numbers are sorted in ascending order.

The general format is:

Array.sort();

Where Array is the name of an array.

Example 1:

var Color= new Array("green", "yellow", "red", "blue", "white", "pink");

var ColorSorted=Color.sort();

alert(ColorSorted); // displays blue,green,pink,red,white,yellow

Example 2:

var Numbers= new Array("9", "4", "7", "3", "1", "5");

var NumbersSorted=Numbers.sort();

alert(NumbersSorted); // displays 1,3,4,5,7,9

Now Read:

How To Create An Array
How To Get Array Size
How To Loop Through An Array
How To Add Elements To An Array
How To Join Array Elements
How To Reverse Element Order In An Array
How To Slice Elements Of An Array Into Pieces
How To Sequentially Sort Elements In An Array

Home | Privacy Policy | Terms Of Use | Contact Us | Work At Home | Online Jobs | Smart Info | Online Jobs | Data Entry Jobs | Paid Surveys | Info | Info | Typing Jobs | Article Archive | Forum Posting Jobs