Home › Forums › Other › Var Shuffle array…I need to have my array NOT shuffle..help! › Reply To: Var Shuffle array…I need to have my array NOT shuffle..help!
May 17, 2016 at 5:01 am
#241780
Participant
You can use the native Array.sort function to order array values.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
var numbers = [1, 9, 3, 6, 7, 11, 45, 194];
var ASC = numbers.sort(function(previous, current) {
return previous - current;
});
var DESC = numbers.sort(function(previous, current) {
return current - previous;
});