summaryrefslogtreecommitdiff
path: root/test/stdsort.myr
blob: 8c8f181c21bec9e8aa6db48cb98f40e2f5bded21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
	;;
}