Sorting arrays using for loop in Javascript
<p>Is it possible to sort arrays in ascending/descending order using the <strong>for loop</strong> JavaScript?</p>

<p>I've been learning JS going through a few practice questions in a textbook before a class test.</p>

<p>Any pointers would be appreciated!</p>

<pre><code>a = Number(prompt("a:"));
b = Number(prompt("b:"));
c = Number(prompt("c:"));
d = Number(prompt("d:"));
e = Number(prompt("e:"));

// find largest element
var test = [a, b, c, d, e];
var biggest = -Infinity;
var biggest_index = -1; {
    for (i = 0; i &lt; test.length; i++) {
        if (test[i] &gt; biggest) {
            biggest = test[i];
            biggest_index = i;
        }
        else;
    }
    alert("The biggest element is " + biggest + " at index " + biggest_index);
}

// move largest element of array to the last index
test[test.length] = biggest;

// get rid of copy
test[biggest_index] = 0;
alert("Unsorted: " + test);

// shuffle ??
</code></pre>
