non-functional - but recursion works, sort works