Skip to content

Sorting

Sorting

The current repository does not ship std.sort or std.vec, so full contest-grade sorting workflows are not yet ergonomic. This page focuses on the pieces that are real today and calls out the missing parts directly.

Current status by problem

ProblemCurrent status
bubble sort on dynamic arraysblocked by missing vector/sort module
merge sortblocked by missing growable arrays
quicksortblocked by missing growable arrays
binary searchfeasible when the array and its length are already available
lower/upper bound helpersfeasible as handwritten functions over Array[i32] inputs

This pattern only needs integers and condition checks:

func first_true(lo: i32, hi: i32) -> i32:
let left: i32 = lo
let right: i32 = hi
while (left < right):
let mid: i32 = (left + right) / 2
if (mid * mid >= 30):
right = mid
else:
left = mid + 1
return left

Time complexity: O(log(hi - lo))
Space complexity: O(1)

Verified pattern: compare-and-order two values

import std.math as math
func smaller_first(left: i32, right: i32) -> i32:
return math.min(left, right)

Time complexity: O(1)
Space complexity: O(1)

When full sorting lands

Once vec and sort are shipped, this page should expand to complete implementations of:

  • bubble sort
  • merge sort
  • quicksort
  • binary search
  • lower bound
  • upper bound

Until then, treat these docs as the current limit of what is practical in the live repository.