Expose a large number of ports should not slow down builder

Related to https://github.com/docker/docker/issues/9021

This improves the behavior of builder when handling a (large) list of ports by preallocating some data when possible. It improves the build speed of https://gist.github.com/karalabe/451f01479f8848973331#file-dockerfile from 20+ seconds to a few seconds on my machine

`EXPOSE` order now will also be more resistant to change as we sort the ports before saving them as image's config.

cc @erikh 
Thanks, nice to know.