title: Javascript: I am having trouble ordering a random string into alphabetical order
body: <p>I am trying to write a function that takes in a random string and returns them in alphabetical order. Can you please look at my code and suggest how I can fix it? I'd like to maintain the spirit of my code as I believe I am close. Big thanks!</p>
  
  <pre><code>var orderInTheCourt = function(str){
    var smallestNumber = 0;
    var newOrder = [];
    for(var i = 0; i &lt; str.length; i++){
      if(String.charCodeAt(str[i]) &lt; smallestNumber){
        smallestNumber += str[i];
        newOrder.unshift(str[i]);
    } else{
        smallestNumber += str[i];
        newOrder.push(str[i]);
      }
    return newOrder.join(''); 
    }
  }
  orderInTheCourt('zyon');
  </code></pre>