- Issue created by @MegaphoneJon
[PR](https://github.com/colemanw/webform_civicrm/pull/925) submitted that uses proposed solution to alphabetize the options.
1.0 Problem/Motivation
State (and probably county) fields aren't listed in alphabetical order in select fields.
2.0 Detailed steps to reproduce (embed screenshots)
Create a webform that has a country, state and county field. Examples of countries with states/provinces out of order include United States, United Kingdom, India, and Bermuda.
This is because JSON object elements aren't ordered, so they're reordered by their key, which is the primary key in `civicrm_state_province`. It's not immediately obvious that they're not alphabetical because many states/provinces are alphabetical in that table, but not everywhere.
3.0 Proposed resolution
The data is returned correctly from the stateProvince and county callbacks, but the browser re-sorts the JSON by id. I'm guessing before PR 813 it sorted by abbreviation, which was more acceptable.
We need to modify fillOptions to convert the object to an array and sort them (e.g. myVar = Object.entries(data).sort(([,a],[,b]) => a > b)
. Then we need to modify the rest of the function to handle the data coming from an array rather than an object.
We'll try to make some time for this if no one else gets to it first, but it's not a priority for us.
Active
6.0
Webform/Drupal
[PR](https://github.com/colemanw/webform_civicrm/pull/925) submitted that uses proposed solution to alphabetize the options.