Created
April 16, 2013 16:47
-
-
Save nelsonic/5397503 to your computer and use it in GitHub Desktop.
ASCII Ascending Order Sort Sort in HTML/JavaScript
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
<html> | |
<h1>Sort</h1> | |
<!-- enable the Chrome Developer Console to see Results --> | |
<script> | |
str = 'X,a,A,C,D,F,1,c,4,3' | |
data = str.split(',') | |
console.dir(data) | |
counter = 0; | |
limit = data.length; | |
end = limit-1; | |
console.log('Limit:'+limit +' | end: '+end ) | |
for(var i = 0; i < limit-1; i++) { | |
// console.log(arr[i]) | |
for(var j =0; j < end; j++) { | |
counter++; | |
// console.log(data[j] +' ' +data[j+1]) | |
if(data[j] > data[j+1]) { | |
// console.log(data[j] +' ' +data[j+1]) | |
swap = data[j+1] | |
data[j+1] = data[j] | |
data[j] = swap | |
} | |
} | |
end--; | |
} | |
console.log('after runnign the loop') | |
console.dir(data) | |
console.log(counter) | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment