don't call sort for every add in history

This moves the call to sort in daemon/history to a function to be
called explicitly when we're done adding elements to the list.

This speeds up `docker ps`.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)