It’s sorting alphabetically, try passing your own sorting function:
var x = new Array();
x[0] = 2.73;
x[1] = 11.17;
x[2] = 3.12;
numberSort = function (a,b) {
return a - b;
};
x.sort(numberSort);
for(var i in x) {
alert(x[i]);
}
More Related Contents:
- Sorting array of object based on range of Numbers of String [closed]
- Convert string into several integer arrays [duplicate]
- Sort out array of object using its value [duplicate]
- Sort array of objects by string property value
- How to sort an array of objects by multiple fields?
- How to sort 2 dimensional array by column value?
- What is the stability of the Array.sort() method in different browsers?
- How can I convert the “arguments” object to an array in JavaScript?
- How to sort array inside collection record in MongoDB?
- Sorting arrays numerically by object property value
- Sort an array of object by a property (with custom order, not alphabetically)
- Sorting objects by property values
- Javascript sort function. Sort by First then by Second
- sort Javascript array by two numeric fields
- How to sort an associative array by its values in Javascript?
- Sort an array with arrays in it by string
- What is the most efficient way to sort an Html Select’s Options by value, while preserving the currently selected item?
- Sort an array based on another array of integers
- How to sort an array based on the length of each element?
- Sort array containing objects based on another array [duplicate]
- Does .sort function change original array?
- Reordering arrays
- Javascript array sort and unique
- Remove duplicate objects from an array using javascript
- Sort an array to have specific items first in the array
- Sort an array of objects by multiple properties
- Sorting an Array of JavaScript Objects a Specific Order (using existing function)
- How does one sort a multi dimensional array by multiple columns in JavaScript?
- How to sort a JavaScript array of objects by nested object property?
- How to sort an array of objects by date?