buble sort in js
bubbleSort(Array) {
let len = Array.length;
for (let i = 0; i < len; i++) { //you can also use "for in", so you don't need the variable "len"
for (let j = 0; j < len; j++) {
if (Array[j] > Array[j + 1]) {
let tmp = Array[j];
Array[j] = Array[j + 1];
Array[j + 1] = tmp;
}
}
}
return Array;
};let bubbleSort = (inputArr) => { let len = inputArr.length; for (let i = 0; i < len; i++) { for (let j = 0; j < len; j++) { if (inputArr[j] > inputArr[j + 1]) { let tmp = inputArr[j]; inputArr[j] = inputArr[j + 1]; inputArr[j + 1] = tmp; } } } return inputArr;};
Also in JavaScript:
- react router dom push
- javascript array remove last
- javascript select first element
- node run parameters
- get the difference between two dates js
- javascript foreach url parameter
- javascript split by comma
- Use multiple conditional operators in the checkSign function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero".
- ./node_modules/browserify-zlib/lib/index.js
- js constructor object
- Drupal 8 get page node current path
- slider js
- uncaught TypeError: $.jajax is not a function
- mobile number validation in javascript
- javascript sort array of objects by key value ascending and descending order
- javascript uppercase string
- javascript detect mobile device
- express receive post data
- state wheteher true or false The charioteer sprinkled sacred water on the king.
- express request body undefined
- generate query string from urlsearchparams
- firebase timestamp to date angular
- avoiding 0 at front in javascript
- class in react