Error: Inferred type argument 'int' doesn't conform to the bound 'Comparable<K>' of the type variable 'K' on 'IterableExtension|sortedBy'.
- 'Comparable' is from 'dart:core'.
Try specifying type arguments explicitly so that they conform to the bounds.
var xx = ['alpha','beta'].sortedBy((element) => element.length);
Does it mean that int does not implement Comparable?
I did not know how to apply the advice given in the error message.
I'm not a Dart expert, and it is unclear to me whether sorting by a criteria of type int is not supported by design when using the sortedBy API, or if I'm doing something wrong, or if there is an issue in the library.
Using Dart 3.2.4 and the collections package, and writing the code below...
['alpha','beta'].sortedBy((element) => element.length);
I get the error printed below:
Does it mean that
int
does not implementComparable
? I did not know how to apply the advice given in the error message.I'm not a Dart expert, and it is unclear to me whether sorting by a criteria of type
int
is not supported by design when using thesortedBy
API, or if I'm doing something wrong, or if there is an issue in the library.