A proof of the Erdos-Szekeres theorem based on the O(n(log n)) algorithm to find the longest increasing subsequence.