Mojo function
sorted
sorted[cmp: fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) -> Bool = lt[::Origin[::Bool](tuple: IntTuple[origin]) -> IntTuple
Sort an IntTuple using the provided comparison function.
This function implements a merge sort algorithm to efficiently sort
the elements of an IntTuple. The sorting is stable and has O(n log n)
time complexity.
Parameters:
- cmp (
fn[ImmutableOrigin, ImmutableOrigin](IntTuple[$0], IntTuple[$1]) -> Bool
): A comparison function that takes twoIntTuple
elements and returns True if the first should come before the second. Defaults to thelt
function which performs lexicographical ordering.
Args:
- tuple (
IntTuple[origin]
): TheIntTuple
to be sorted.
Returns:
A new IntTuple
containing the same elements as the input but sorted according to the comparison function.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!