diff --git a/lib/src/iterable_extensions.dart b/lib/src/iterable_extensions.dart index 1bf4b3e..66c35f6 100644 --- a/lib/src/iterable_extensions.dart +++ b/lib/src/iterable_extensions.dart @@ -72,6 +72,22 @@ extension IterableExtension on Iterable { /// /// The elements are ordered by the natural ordering of the /// property [keyOf] of the element. + /// + /// Due to https://github.com/dart-lang/sdk/issues/43763 + /// if you are comparing using int, you will need to use the `num` type + /// annotation instead, e.g. + /// + /// ```dart + /// class Foo { + /// final int bar; + /// Foo(this.bar); + /// } + /// + /// final foos = [Foo(1), Foo(2), Foo(3)]; + /// // final sortedFoos = foos.sortedBy((foo) => foo.bar); // Error + /// final sortedFoos = foos.sortedBy((foo) => foo.bar as num); // Works + /// final alsoWorks = foos.sortedBy((foo) => foo.bar); // Works + /// ``` List sortedBy>(K Function(T element) keyOf) { var elements = [...this]; mergeSortBy(elements, keyOf, compareComparable);