Linked List with Sorting

by Erik East

HTML

<body>

<h1>Linked List with Sorting</h1>
<p>Give your pennance (max 20 characters):<br/>--</br>
    <b>NOTE:</b> - The program is case-sensitive and number-sensitive. It will sort the entries based on ASCII values--numbers take highest priority, and go towards the head of the list. Then uppercase letters, and then lowercase letters.</p><br/>

<input type='text' id='number' size='20'onkeypress='captureEnter(event);'><br/>
<p id="demo"></p>
    <script>
        // Define the link object
        function Link(_id, _value, _next) {

            this.id = _id; // The id of the current link
            this.value = _value; // The value stored
            this.next = _next; // a pointer to the next link, this is 0 if it is the last link in the chain
        }

        Link.prototype.theScribe = function () {
            return "" + this.value +
                    " --Location: " + this.id +
                    " - Points To: " + this.next + "<br/>";
        };


        // Define the Chain object
        function Chain(_firstValue) { // We will define the chain with the first link defined
            this.length = 1;
            // I like to keep track of the first link, not really necessary
            this.head = new Link(1, _firstValue, null);
            // I need a place to store this links - an array will work fine and is pretty much one of the few options you have in JS
            this.linkStorage = [];
            // Oh yea - since we aren't creating an empty Chain - let's fill in that first value
            this.linkStorage.push(this.head);

        }

        Chain.prototype.lastLink = function () {
            // A function to find the last link in the chain
            return this.linkStorage[this.length - 1];
        };

        Chain.prototype.Finder = function(eyeDee){
            for(var i=0; i < this.length; i++){
                if(eyeDee == this.linkStorage[i].id)
                    return this.linkStorage[i];
            }
        };

       ...