Sort the tree into an array

O(n)

var tree = new BinTreeMap[Int, String]
for i in [4, 2, 1, 5, 3] do tree[i] = "n{i}"
assert tree.sort == ["n1", "n2", "n3", "n4", "n5"]

Property definitions

trees $ BinTreeMap :: sort
	# Sort the tree into an array
	# O(n)
	#
	#     var tree = new BinTreeMap[Int, String]
	#     for i in [4, 2, 1, 5, 3] do tree[i] = "n{i}"
	#     assert tree.sort == ["n1", "n2", "n3", "n4", "n5"]
	fun sort: Array[E] do
		var sorted = new Array[E]
		if root == null then return sorted
		sort_down(root.as(not null), sorted)
		return sorted
	end
lib/trees/bintree.nit:307,2--318,4