3
I have an array with several numbers, these numbers are positive, negative and decimal as well:
var array = [365, -1.304, -17.803, -3.529, -3.602, -2.942, -2.074, -115]
I need to sort this array of MINOR to the GREATER. The result that was to be expected is:
[-17.803, -3.602, -3.529, -2.942, -2.074, -1.304, -115, 365]
But instead this is coming out:
[-115, -17.803, -3.602, -3.529, -2.942, -2.074, -1.304, 365]
The code I’m using to order:
GraphOne[Regional].sort(function(a,b){return a > b});
@leofontes, but -17,803 is 17,000. So 17,000 is farther than -115
– Alisson Acioli
Man, are you using
.
. This is decimal separator– Sorack
@Alissonacioli yes I had read in the English convention so it made sense my comment, but you’re thinking in Portuguese.
– leofontes