New Sort

by arosado417

HTML

<input type="button" id="createrandom" value="Create Random String List" onclick= "randomString()" />
<div id="output1"></div>
<br />
<input type="button" id="bubblesort" value="Bubble Sort" onclick="startBubble()" />
<div id="output2"></div>
<br />
<input type="button" id="quicksort" value="Quick Sort" onclick="startQuickSort()" />
<div id="output3"></div>
<br />
<input type="button" id="insert string" value="Insert String" onclick="insertString()"/>
<br />
<div id="output4"></div>
<input id="a" Value="1ab" />

JavaScript

function LinkedList() {
  this.head = null;
  this.tail = null;
  this.length = 0;
}

function Node() {
  this.next = null;
  this.prev = null;
  this.content = null;
}

LinkedList.prototype.add = function(_content) {
  var node = new Node();
  node.content = _content;

  if (this.head == null) {
    this.head = node;
    this.length = 1;
    return node.content;
  }

  if (this.tail == null) {
    this.tail = node;
    this.tail.prev = this.head;
    this.head.next = this.tail;
    this.length++;
    return node.content;
  }
  this.tail.next = node;
  node.prev = this.tail;
  this.tail = node;
  this.length++;
  return node.content;
}

LinkedList.prototype.addSorted = function(_content) {
  if (this.head == null) {
    return this.add(_content);
  }
  var node = new Node();
  node.content = _content;
  if (_content < this.head.content) {
    this.head.prev = node;
    node.next = this.head;
    this.head = node;
    return node.content;
  }
  //if current node is head
  var curnode = this.head;
 
 while( curnode.next != null && curnode.next.content < _content ){
 curnode = curnode.next;
 }
  if(curnode.next != null){
  node.next = curnode.next;
  node.next.prev = node;
  }
  curnode.next = node;
  node.prev = curnode;
 
 return curnode;
}
LinkedList.prototype.print = function() {
  if (this.head == null) return "Empty List";
  var s = "";
  var node = this.head;
  while (node != null) {
    s += node.content + "  " + " ,";
    node = node.next;
  }
  return s;
}




LinkedList.prototype.bubbleSort = function(){
var i= this.head;
console.log("i is: " + i.content);
console.log("j is: " + j.content);


for (i = this.head; i != null; i = i.next){
for(j = i.next; j != null; j = j.next){
     if(i.content > j.content){
     var temp = i.content;
     i.content = j.content;
     j.content = temp;
       
         }
        }   
     	}
   return i;
   }
LinkedList.prototype.quickSort = function(){
var j = this.head;
var pivot = this.tail;


for (i = this.head; i !=...