Avoid StackOverflowErrors when sorting and zipping.

Change the implementations of sort() and zipWith() from recursive to iterative, to avoid blowing the stack on large lists.