title: How to alphabetically sort a JQuery UI sortable?
body: <p>I was wondering if it is possible to have a JQuery UI sortable default to be alphabetically sorted.  If so, is it also possible to keep it alphabetically sorted in real time if I add items to the sortable?  Below is my code:</p>
  
  <pre><code>// Adds item to sortable list
  $(".addButton").click(function(e) {
      e.preventDefault();
      // set var item to be the string inputted by the user
      var item = $("input[name='brewItem']").val();
      // parses input string, splitting at commas into liArray containing substrings as elements
      var liArray = item.split(", ");
      // for loop to add each brew to the sortable list (length-1 because last element in array is empty string)
      for (var i = 0; i &lt; liArray.length-1; i++) {
          // sets var $li to the string in the ith index of liArray
          var $li = $("&lt;li class='ui-state-default'/&gt;").text(liArray[i]);
  
  
  
          // adds var $li to gui
          $("#sortable").append($li);
      };
      // refreshes the page so var $li shows up
      $("#sortable").sortable("refresh");
  });
  </code></pre>
  
  <p>I'm not quite sure where or how to implement this.  Any help is appreciated, thanks!</p>