States sorting now works