title: Jquery pass extra variable to sort function
body: <p>I need to write a common sort function. I am using jQuery for sorting. jQuery sort function only accepts two parameters as input. But I want to pass another parameter to that function. How can I do that?</p>
  
  <p>Something like this:</p>
  
  <pre><code> obj.sort(StringSort);
   obj2.sort(StringSort);
  
   function StringSort(a, b, desc)
   {
      var aText = $(a).attr(desc).toLowerCase();
      var bText = $(b).attr(desc).toLowerCase();
  
      if(aText == bText)
        return 0;
  
      return aText &gt; bText ? 1 : -1;
   }
  </code></pre>