Added sorting to agents