Added sorting for states