-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsortingArray.js
More file actions
27 lines (26 loc) · 744 Bytes
/
sortingArray.js
File metadata and controls
27 lines (26 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const sortingArray = (array) =>{
for(let i=0; i<array.length; i++){
for(let j=0; j<array.length; j++){
if(array[j] > array[j+1]){
let temp = array[j];
array[j] = array[j+1]
array[j+1] = temp;
}
}
}
return array
}
console.log(sortingArray([3,5,690,7,8,45,67,89]))
// const singleArray = (array) =>{
// for(let i=0; i< array.length; i++){
// for(let j=i+1; i< array.length; j++){
// if(array[i] > array[j]){
// let temp = array[i];
// array[i] = array[j];
// array[j] = temp;
// }
// }
// }
// return array;
// }
// console.log(singleArray([34,23,11,22,56,67,89,43]))