O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Ordering of elements

Several collections implicitly support ordering of elements and help in sorting them without any effort. We can find any element with or without the filter predicate or perform a binary search within a sorted array to improve the performance of large collections. We can sort collections by providing a collection-compare function via a comparator or an object-compare method via the Comparable interface.

The Comparable interface

There are many core classes in Dart that support a native comparison via the implementation of the Comparable interface. You can implement the Comparable interface in classes that you have created to use them in collections to prevent unusual results of the sorting operation. Here, we will modify the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required