title: javascript sorting array of objects by string property
body: <p>I am trying to sort an array of object by a property <code>title</code>. This the code snippet that I am running but it does not sort anything. The array is displayed as it is. P.S I looked at previous similar questions. This one for example <a href="https://stackoverflow.com/questions/1129216/sort-array-of-objects-by-string-property-value-in-javascript">here</a> suggests and uses the same method I am using.</p>
  
  <p>The javascript:</p>
  
  <pre><code>function sortLibrary() {
      // var library is defined, use it in your code
      // use console.log(library) to output the sorted library data
      console.log("inside sort");
      library.sort(function(a,b){return a.title - b.title;});
      console.log(library);
  } 
  
  // tail starts here
  var library = [
      {
          author: 'Bill Gates',
          title: 'The Road Ahead',
          libraryID: 1254
      },
      {
          author: 'Steve Jobs',
          title: 'Walter Isaacson',
          libraryID: 4264
      },
      {
          author: 'Suzanne Collins',
          title: 'Mockingjay: The Final Book of The Hunger Games',
          libraryID: 3245
      }
  ];
  
  sortLibrary();
  </code></pre>
  
  <p>The html code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;h1&gt; Test Page &lt;/h1&gt;
  &lt;script src="myscript.js"&gt; &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>