title: Dart: sort list of maps by double
body: <p>I have a list of maps in dart that I would like to sort.</p>
  
  <p>The list I use: </p>
  
  <pre><code>List&lt;myModel&gt; myList; 
  </code></pre>
  
  <p>(with maps inside):</p>
  
  <p>(I created a model called 'myModel', so if I want to get the views: so I can use: myList[index].views to get the views of a map).</p>
  
  <p>I tried this code:</p>
  
  <pre><code>setState(() {
          filteredList = SplayTreeMap.from(
              myList,
              (a, b) =&gt; int.parse(myList[a].views)
                  .compareTo(int.parse(myList[b].views)));
        });
  </code></pre>
  
  <p>(I want to sort the views, hight to low).</p>
  
  <p>But I get this error:</p>
  
  <pre><code>error: A value of type 'SplayTreeMap' can't be assigned to a variable of type 'List&lt;myModel&gt;'.
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT:</p>
  
  <p>I 'query' my list this way.</p>
  
  <pre><code>    filteredList = myList
          .where((snapshot) =&gt; snapshot.views &gt; 0)
          .toList();
  </code></pre>
  
  <p>This works...</p>
  
  <p>Is there a possibility to sort that way?</p>