bynk.types.key_not_orderable
Error A sortBy/sortByDescending/min/max key function does not return an orderable type. The key must be an Ord type, on a List and on a storage Query alike.
sortBy, sortByDescending, min and max order a list, or a storage Query, by the value the key function returns, so that value needs a total order. A record or sum is not ordered by accident, because opting in makes field and variant order significant. Return a field that is already orderable, or add derives Ord to the type. The operators < and > on an unordered type are bynk.types.not_orderable.
Example
type Item = { id: Int }
fn byId(items: List[Item]) -> List[Item] { items.sortBy((i) => i) // ✗ `Item` has no order}
fn byId(items: List[Item]) -> List[Item] { items.sortBy((i) => i.id) // ✓ `Int` does}In the Book
See also
- Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.key_not_orderableshows the same from the installed toolchain, without a network.