title: Sort a list of objects in Dart
body: <p>I am trying to sort a list of objects called "posts" with the following function. It does not seem to be working as I expect and I am not sure why. Title values in "posts" BEFORE called on function are 66666666666, new one, Luke Kady, Rory's rink, new post. AFTER sorted on title: 66666666666, Luke Kady, new one, new post, Rory's rink. Also tried adding in <code>.toLowerCaase()</code> for titles and got same results.</p>
  
  <pre><code>void sortPosts(String sortBy) {
     if (sortBy == "Title") {
        posts.sort((a, b) =&gt; a.title[0].compareTo(b.title[0]));
     } else {
        posts.sort((a, b) =&gt; a.price.compareTo(b.price));
     }
  }
  </code></pre>