Fixed wrong order of history items.

The order of the history items available by '/<up>' or ':<up>' was
wrong, the first items should be the latest added command and not the
oldest one.

This patch fixes also wrong ordering of history entries in the files in case
when the number of items in the files is higher than the configured maximum
history items.