<commit_before>import Ember from 'ember';
import { getAllCountryNames, getCountryName, getCountryCallingCode } from 'ember-cli-countries/utils/countries';
import layout from '../templates/components/uni-mobile-number';

const { Component } = Ember;
const options = getOptions().sort(sortByName);

function getOptions(){

  return getAllCountryNames().map((country) => {
    let { key } = country;

    return { key, value: `${getCountryName(key)} (${getCountryCallingCode(key)})` };
  });
}

function sortByName(nameA, nameB) {
  let a = nameA.toUpperCase();
  let b = nameB.toUpperCase();

  if (a.value < b.value) {
    return -1;
  }
  if (a.value > b.value) {
    return 1;
  }

  return 0;
}

export default Component.extend({
  classNames: ['uni-mobile-number'],
  classNameBindings: ['hasError:uni-mobile-number--error'],
  layout,
  number: null,
  language: null,
  maxLength: '15',
  countrySelected: null,
  selectPlaceholder: null,

  isOpen: false,
  options,<commit_msg>fixed previous implementation<commit_after>import Ember from 'ember';
import { getAllCountryNames, getCountryName, getCountryCallingCode } from 'ember-cli-countries/utils/countries';
import layout from '../templates/components/uni-mobile-number';

const { Component } = Ember;
const options = getOptions().sort(sortByName);

function getOptions() {

  return getAllCountryNames().map((country) => {
    let { key } = country;

    return { key, value: `${getCountryName(key)} (${getCountryCallingCode(key)})` };
  });
}

function sortByName(nameA, nameB) {
  let a = nameA.toUpperCase();
  let b = nameB.toUpperCase();

  if (a.value < b.value) {
    return -1;
  }

  if (a.value > b.value) {
    return 1;
  }

  return 0;
}

export default Component.extend({
  classNames: ['uni-mobile-number'],
  classNameBindings: ['hasError:uni-mobile-number--error'],
  layout,
  number: null,
  language: null,
  maxLength: '15',
  countrySelected: null,
  selectPlaceholder: null,

  isOpen: false,
  options,
{'fraction_non_alphanumeric': 0.14904330312185296, 'fraction_numerical': 0.005035246727089627, 'mean_word_length': 4.215223097112861, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1196628', 'n_tokens_mistral': 663, 'n_tokens_neox': 649, 'n_words': 149}