baml.Sortable

Sorting for collections whose elements have a natural order.

Reference version

Signature

interface baml.Sortable

Sorting for collections whose elements have a natural order.

Implemented for T[] whenever T implements baml.ops.Compare. That ordering is total and throws never, so sorting is infallible: sort() has no error channel and needs no associated error type.

class Resume {
  name string
  implements baml.ops.Equals {
    function eq(self, other: Self) -> bool throws never { self.name == other.name }
  }
  implements baml.ops.Compare {
    function cmp(self, other: Self) -> baml.ops.Ordering throws never {
      self.name.cmp(other.name)
    }
  }
}

resumes.sort()

Source:<builtin>/baml/sortable.bamlbytes 665733

Required instance methods

function

sort

(self) -> Self throws never