Sunday, February 12, 2017

sorter

sort the list              debugged
<input id="atnbg20170212su1708" /><a href="javascript:atnbg20170212su1708()" style="color:pink">sort the list</a><div id="atnbg20170212su1708partlysorted" style="color:pink"></div><div id="atnbg20170212su1708sorted" style="color:burlywood"></div>



revision

<input id="atnbg20170212su1708" /><a href="javascript:atnbg20170212su1708()" style="color:pink">sort the list</a><div id="atnbg20170212su1708sorted" style="color:burlywood"></div>

<script>

function atnbg20170212su1708() {
var thelist = document.getElementById("atnbg20170212su1708")
var thepartlysortedlist = thelist.value
var thesortedlist = ""

function findthenexturl(thepartlysortedlist) {
var thepartlysortedarray = thepartlysortedlist.split(",")
var thenexturl = thepartlysortedarray[0]
function symbol(url) {return url.split("/")[url.split("/").length - 1].split("c")[0]}
for (var i = 0; i < thepartlysortedarray.length; i = i + 1) {
if (symbol(thepartlysortedarray[i]) < symbol(thenexturl)) {thenexturl = thepartlysortedarray[i]}}
return thenexturl}

function removetheurl(thepartlysortedlist,theurl) {
var thepartlysortedarray = thepartlysortedlist.split(",")
var thereplacementlist = ""
for (var i = 0; i < thepartlysortedarray.length; i = i + 1) {
if (thepartlysortedarray[i] != theurl) {
thereplacementlist = thereplacementlist + thepartlysortedlist[i]
if (i < thepartlysortedlist.length - 1) {thereplacementlist = thereplacementlist + ","}}}
return thereplacementlist}

for (var i = 0; i < thelist.length; i = i + 1) {

var thenexturl = findthenexturl(thepartlysortedlist)

thesortedlist = thesortedlist + thenexturl

var thepartlysortedarray = thepartlysortedlist.split(",")
if (i < thepartlysortedarray.length - 1) {thesortedlist = thesortedlist +  ","}

thepartlysortedlist = removetheurl(thepartlysortedlist,theurl)}

document.getElementById("").innerHTML = thesortedlist

}



</script>

revision


<script>

function atnbg20170212su1708() {
var thepartlysortedlist = document.getElementById("atnbg20170212su1708partlysorted")
thepartlysortedlist.innerHTML = document.getElementById("atnbg20170212su1708").value

for (var i = 0; i < thelist.length; i = i + 1) {

// find the next url on the partly sorted list
// add the next url to the sorted list
// remove the url from the partly sorted list

function findthenexturl() {
var thepartlysortedlist = document.getElementById("atnbg20170212su1708partlysorted")
var thepartlysortedarray = thepartlysortedlist.innerHTML.split(",")
var thenexturl = thepartlysortedarray[0]
function symbol(url) {return url.split("/")[url.split("/").length - 1].split("c")[0]}
for (var i = 0; i < thepartlysortedarray.length; i = i + 1) {
if (symbol(thepartlysortedarray[i]) < symbol(thenexturl)) {thenexturl = thepartlysortedarray[i]}}
return thenexturl}

var thenexturl = findthenexturl()

function addthenexturl(thenexturl) {
var thenewlist = document.getElementById("atnbg20170212su1708sorted")
thenewlist.innerHTML = thenewlist.innerHTML + thenexturl}

addthenexturl(thenexturl)

if (i < list.length - 1) {
var thenewlist = document.getElementById("atnbg20170212su1708sorted")
thenewlist.innerHTML = thenewlist.innerHTML +  ","}

function removetheurl(theurl) {
var thepartlysortedlist = document.getElementById("atnbg20170212su1708partlysorted")
var thepartlysortedarray = thepartlysortedlist.innerHTML.split(",")
var thereplacementlist = ""
for (var i = 0; i < thepartlysortedarray.length; i = i + 1) {
if (thepartlysortedarray[i] != theurl) {
thereplacementlist = thereplacementlist + thepartlysortedlist[i]
if (i < thepartlysortedlist.length - 1) {thereplacementlist = thereplacementlist + ","}}}}



</script>
revision


<script>

function atnbg20170212su1708() {
var thepartlysortedlist = document.getElementById("atnbg20170212su1708partlysorted")
thepartlysortedlist.innerHTML = document.getElementById("atnbg20170212su1708").value

var thelist = document.getElementById("atnbg20170212su1708").value
var thelistarray = thelist.split(",")
var sortedlist = ""
for (var i = 0; i < thelist.length; i = i + 1) {

// find the next url on the partly sorted list
// add the next url to the sorted list
// remove the url from the partly sorted list

sortedlist = sortedlist + remove(earliestvalue(thelistarray),thelistarray)}
function earliestvalue(thelistarray)) {var earliestvalue = 0
for (var i = 0; i < thelistarray.length; i = i + 1) {
if (thelistarray[i] < thelistarray[earliestvalue]) {earliestvalue = i}}return earliestvalue}
function remove(thisurl,thelistarray) {var newlist = ""
for (var i = 0; i < thelistarray.length; i = i + 1) {
if (thelistarray[i] != thisurl) {if (i > 0) {newlist = newlist + ","}
newlist = newlist + thelistarray[i]};return newlist}
document.getElementById("atnbg20170212su1708sorted").innerHTML = }

function findthenexturl() {
var thepartlysortedlist = document.getElementById("atnbg20170212su1708partlysorted")
var thepartlysortedarray = thepartlysortedlist.innerHTML.split(",")
var thenexturl = thepartlysortedarray[0]
function symbol(url) {return url.split("/")[url.split("/").length - 1].split("c")[0]}
for (var i = 0; i < thepartlysortedarray.length; i = i + 1) {
if (symbol(thepartlysortedarray[i]) < symbol(thenexturl)) {thenexturl = thepartlysortedarray[i]}}
return thenexturl}

var thenexturl = findthenexturl()

function addthenexturl(thenexturl)



</script>


<script>

function atnbg20170212su1708() {
var thelist = document.getElementById("atnbg20170212su1708")
function removefromlist(theurl,thelist) {
var thelistarray = thelist.value.split(",")
thelist.value = ""
for (var i = 0; i < thelistarray.length; i = i + 1) {
var thisurl = thelistarray[i]
if (this != theurl) {
if (i > 0) {thelist.value = thelist.value + ","}
thelist.value = thelist.value + thisurl}}
document.getElementById("atnbg20170212su1708sorted").innerHTML = thelist.value}

</script>

No comments:

Post a Comment