<p>The <code>compare</code> function must act as a <a href="../../dart-core/Comparator.html">Comparator</a>.</p>
<pre class="language-dart"><code>List&lt;String&gt; numbers = ['two', 'three', 'four'];
// Sort from shortest to longest.
numbers.sort((a, b) =&gt; a.length.compareTo(b.length));
print(numbers);  // [two, four, three]
</code></pre>
<p>The default List implementations use <a href="../../dart-core/Comparable/compare.html">Comparable.compare</a> if
<code>compare</code> is omitted.</p>
<pre class="la