function sortStates(a, b, value) {
  const aLower = a.name.toLowerCase()
  const bLower = b.name.toLowerCase()
  const valueLower = value.toLowerCase()
  const queryPosA = aLower.indexOf(valueLower)
  const queryPosB = bLower.indexOf(valueLower)
  if (queryPosA !== queryPosB) {
    return queryPosA - queryPosB
  }
  return aLower < bLower ? -1 : 1
}
An example of how to implement a relevancy-based sorting method. States are
sorted based on the location of the match - For example, a search for "or"
will return "Oregon" before "North Carolina" even though "North Carolina"
would normally sort above Oregon. Strings where the match is in the same
location (or there is no match) will be sorted alphabetically - For example,
a search for "or" would return "North Carolina" above "North Dakota".