Line data Source code
1 : // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 : // for details. All rights reserved. Use of this source code is governed by a 3 : // BSD-style license that can be found in the LICENSE file. 4 : 5 : /// A [Comparator] that asserts that its first argument is comparable. 6 : /// 7 : /// The function behaves just like [List.sort]'s 8 : /// default comparison function. It is entirely dynamic in its testing. 9 : /// 10 : /// Should be used when optimistically comparing object that are assumed 11 : /// to be comparable. 12 : /// If the elements are known to be comparable, use [compareComparable]. 13 0 : int defaultCompare(Object? value1, Object? value2) => 14 0 : (value1 as Comparable<Object?>).compareTo(value2); 15 : 16 : /// A reusable identity function at any type. 17 0 : T identity<T>(T value) => value; 18 : 19 : /// A reusable typed comparable comparator. 20 0 : int compareComparable<T extends Comparable<T>>(T a, T b) => a.compareTo(b);