@jZero/

ReadySizzlingDominspector

JavaScript

No description

fork
loading
main.js
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
// bubble sort 

let data = [44, 55, 88, 99, 180, 0, 7, 4,];

function bsort(data){
	let arr = data.from(0);
	for(let i=0; i<arr.length;i++){
		for(let k=0;k<arr.length;k++){
			let temp = 0;
			if(arr[i] < arr[k]){
				//swap values
				temp = arr[i];
				arr[i] = arr[k];
				arr[k] = temp;
			}
		}
	}
	console.log(data + " sort completed " + arr);
	return arr;
}

// test
console.log(data);
console.log(bsort(data));


Native Browser JavaScript