sundialSort (trolling)

a very bad way to see if an array is already sorted, using only the == and != operators.

by outRideACrisis

HTML

<svg id="dial" height="40" width="40" transform = >
  
</svg>

JavaScript

sunDialsort = function (values)
{
    var data = values.toString();
    //count number of values 
    var len = data.match(/,/g).length + 1; //<1>
    //find the sig figs we are working with (longest number)
    var sizeArray = [],
        j = 0;
    for (var i = 0; i < data.length; i++)
    {
        switch (data.charAt(i))
        {
        case ("."):
            break; //dont count
        case (","):
            sizeArray.push(j);
            j = 0;
            break;
        default:
            j++;
        }
    }
    sizeArray.push(j);
    var precision = Math.max.apply(Math, sizeArray);
    //assume min/max based on number of characters
    var max = Math.pow(10, precision);
    var min = max * -1;
    console.log(min + "," + max + "," + len);
    //for each number make a horizontal svg line of length (i*acuuracy)     
    var pathLen = 1 / len;
    var path, percent, width, rotate, x, bbox, notTheFirstTimeRound, ascending;
    var sorted = true;
    for (i = 0; i < len; i++)
    {
        path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
        path.setAttribute("stroke", "blue"); //green is not a creative colour
        path.setAttribute("d", "M0 20 h " + (i * pathLen));
        percent = (values[i] - min) / (max - min);
        rotate = 90 - (percent * 180);
        path.setAttribute("transform", "rotate(" + rotate + ")");
        document.getElementById("dial").appendChild(path);
        bbox = document.getElementById("dial").getBBox();
        if (notTheFirstTimeRound)
        {
            ascending = (bbox.width != width && x == bbox.x);
            console.log("test " + ascending);
            width = bbox.width;
            if (!ascending)
            {
                sorted = false
            }
        }
        else
        {
            x = bbox.x;
            width = bbox.width;
            notTheFirstTimeRound = true;
        }
    }
    return sorted
};
alert(sunDialsort([1, 2, 3, 3, 4, 5]));