compare method

int compare (
  1. Comparable a,
  2. Comparable b
)

A Comparator that compares one comparable to another.

It returns the result of a.compareTo(b). The call may fail at run-time if a is not comparable to the type of b.

This utility function is used as the default comparator for ordering collections, for example in the List sort function.

Implementation

static int compare(Comparable a, Comparable b) => a.compareTo(b);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/Comparable/compare.html