shithub: mc

ref: b65a821ba2d8c753e974b02e541229dfd6754a6a
dir: /test/stdsort.myr/

View raw version
use std

const main = {
	var a = [
		3, 5, 4, 9, 7, 2, 6, 0, 1, 8,
	]
	var b = [
	       3, 4, 5, 1, 2, 6, 7, 8, 9, 10
	]
	var c = [
		"a", "aa", "b", "C", "Cc", "cC", "d", "f", "fuckit", "go",
	]

	std.sort(a[:], intcmp)
	for v in a
		std.put("%i\n", v)
	;;
	std.put("---\n")
	std.sort(b[:], std.numcmp)
	for v in b
		std.put("%i\n", v)
	;;
	std.put("---\n")
	std.sort(c[:], std.strcmp)
	for v in c
		std.put("%s\n", v)
	;;
}

const intcmp = {a, b
	if a < b
		-> `std.Before
	elif a == b
		-> `std.Equal
	else
		-> `std.After
	;;
}