sort() can be used on lists of integers without further ado.
But if I define my own type, which trait shall I implement on it so that lists made of it can be sorted?
@value
struct MyStruct(LessThanOrEqualComparable):
fn __le__(self, other: Self) -> Bool:
return True
fn main() raises:
var my_integers = List(3,1,2)
sort(my_integers)
print(" ".join(my_integers))
var my_objects = List(MyStruct())
sort(my_objects)
error: no matching function in call to 'sort'
note: candidate not viable: failed to infer parameter #0