Created
April 18, 2015 12:26
-
-
Save lukeo357/637f82b0718c5e06e49f to your computer and use it in GitHub Desktop.
JSV JSV // source http://jsbin.com/cotive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="JSV"> | |
<meta charset="utf-8"> | |
<title>JSV</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//bubbleSort | |
var datArray = [3,4,6,2,1,5,8,7,12,9,11,10]; | |
function bubbleSort(data) { | |
for(var k = 0; k <= data.length/2; k++) { | |
for(var i = 0; i < data.length - k; i++) { | |
if(data[i] > data[i + 1]) { | |
var temp = data[i]; | |
data[i] = data[i + 1]; | |
data[i + 1] = temp; | |
} | |
} | |
} | |
return data; | |
} | |
bubbleSort(datArray); | |
console.log(datArray); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
//bubbleSort | |
var datArray = [3,4,6,2,1,5,8,7,12,9,11,10]; | |
function bubbleSort(data) { | |
for(var k = 0; k <= data.length/2; k++) { | |
for(var i = 0; i < data.length - k; i++) { | |
if(data[i] > data[i + 1]) { | |
var temp = data[i]; | |
data[i] = data[i + 1]; | |
data[i + 1] = temp; | |
} | |
} | |
} | |
return data; | |
} | |
bubbleSort(datArray); | |
console.log(datArray); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bubbleSort | |
var datArray = [3,4,6,2,1,5,8,7,12,9,11,10]; | |
function bubbleSort(data) { | |
for(var k = 0; k <= data.length/2; k++) { | |
for(var i = 0; i < data.length - k; i++) { | |
if(data[i] > data[i + 1]) { | |
var temp = data[i]; | |
data[i] = data[i + 1]; | |
data[i + 1] = temp; | |
} | |
} | |
} | |
return data; | |
} | |
bubbleSort(datArray); | |
console.log(datArray); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment