Answers for "ascending order sort javascript without sort function"

1

how to sort array without using sort method in javascript

function bubbleSort(array) {
  var done = false;
  while (!done) {
    done = true;
    for (var i = 1; i < array.length; i += 1) {
      if (array[i - 1] > array[i]) {
        done = false;
        var tmp = array[i - 1];
        array[i - 1] = array[i];
        array[i] = tmp;
      }
    }
  }

  return array;
}

var numbers = [12, 10, 15, 11, 14, 13, 16];
bubbleSort(numbers);
console.log(numbers);
Posted by: Guest on October-17-2020
1

javascript sort array in ascending order

//sorts arrays of numbers
function myFunction() {
  points.sort(function(a, b){return a-b});
  document.getElementById("demo").innerHTML = points;
}
Posted by: Guest on March-25-2020
0

ascending order sort javascript without sort function

1233455
Posted by: Guest on March-29-2021

Code answers related to "ascending order sort javascript without sort function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language