Description
The sort() method sorts the elements of an array.
This method has the form:
Array.sort(func)
| Parameter | Description |
|---|---|
| func | (optional)A function that defines the sort order |
Note: By default, the sort() method sorts the elements alphabetically and ascending.
Examples
The following example shows the basic use of this method.
<script>
var cols = [ "Red", "Green", "Blue" ];
document.write(cols.sort());
</script>
This produces the following result:
Browser Support
| Firefox | IE | Chrome | Opera | Safari |
|---|---|---|---|---|
