Added sorting of ids to be more logical