Question
array sort in descending order doesn't work
"Please use "Attach Code" to include any sample code in the
message.". MMM. There's no attach code link.
The array.sort function doesn't sort in descending order, the output is the same.
Formatted: http://pastebin.com/f3a320622
//Ascending
var array = [{number:1}, {number:2}];
array.sort(function(a,b) {
if (a.number < b.number)
return -1;
else if (a.number > b.number)
return 1;
else
return 0;
});
array.trace();
Formatted: http://pastebin.com/m625c53df
//Descending
var array = [{number:1}, {number:2}];
array.sort(function(a,b) {
if (a.number < b.number)
return -1;
else if (a.number > b.number)
return 1;
else
return 0;
}, Array.DESCENDING);
array.trace();
Here's the additional functions (trace):
http://pastebin.com/f42937d95
Since they can't even fix the attach code thing, i have no hope they can fix this. But whatever.
The array.sort function doesn't sort in descending order, the output is the same.
Formatted: http://pastebin.com/f3a320622
//Ascending
var array = [{number:1}, {number:2}];
array.sort(function(a,b) {
if (a.number < b.number)
return -1;
else if (a.number > b.number)
return 1;
else
return 0;
});
array.trace();
Formatted: http://pastebin.com/m625c53df
//Descending
var array = [{number:1}, {number:2}];
array.sort(function(a,b) {
if (a.number < b.number)
return -1;
else if (a.number > b.number)
return 1;
else
return 0;
}, Array.DESCENDING);
array.trace();
Here's the additional functions (trace):
http://pastebin.com/f42937d95
Since they can't even fix the attach code thing, i have no hope they can fix this. But whatever.
