Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let testArray = [10, 25, 25, 12, 22, 11, 90];
- console.log(sort(testArray));
- function sort(array){
- let length = array.length;
- for(let i = 0; i < length; i++ ){
- let j = 0;
- while(j < length - i - 1 ){
- if(array[j] > array[j + 1]){
- let temp = array[j];
- array[j] = array[j + 1];
- array[j + 1] = temp;
- }
- j++;
- }
- }
- return array;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement