Use a local copy of the errors array.
Added sorting to document messages table.