title: How and where can I sort an array of Django <django.utils.functional.lazy> objects?
body: <p>I have a list of tuples with countries/cities combinations from which I populate a select field in django. </p>
  
  <p>I'm loading placeholders for the select options using a configparser in my <code>settings.py</code>:</p>
  
  <pre><code>scope_value_list = dict(raw_parser.items('scope_value_list'))
  CATEGORIES = SimpleNamespace(**{
    "SCOPE_CHOICES": [(code_tuple[1], _(scope_value_list[code_tuple[0]].partition('{% trans "')[2].partition('" %}')[0])) for code_tuple in raw_parser.items('scope_list')],
    ...
  })
  </code></pre>
  
  <p>A bit cumbersome but I cannot provide hardcoded translations outside of the django.po/mo files and haven't found a better solution than to include my .ini file in my <code>makemessages</code> calls and then strip the translation flags as shown above to build my list of choices.</p>
  
  <p>However this means my SCOPE_CHOICES contains lazy-translated-objects and not actual translations, so I have:</p>
  
  <pre><code>[('eu', &lt;django.utils.functional.lazy.&lt;locals&gt;.__proxy__ object at 0x7ff11f7ad470&gt;), ('eu-at', &lt;django.utils.functional.lazy.&lt;locals&gt;.__proxy__ object at 0x7ff11f7adba8&gt;), ('eu-be', &lt;django.utils.functional.lazy.&lt;locals&gt;.__proxy__ object at 0x7ff11f7adc50&gt;), ('eu-bg', &lt;django.utils.functional.lazy.&lt;locals&gt;.__proxy__ object at 0x7ff11f7adcc0&gt;), ('eu-hr', &lt;django.utils.functional.lazy.&lt;locals&gt;.__proxy__ object at 0x7ff11f7b6278&gt;),...]
  </code></pre>
  
  <p>This all works (yay), but when I display the select field in any template it will go by the order in the tuple (array would be the same), so countries are not sorted A-Z by their actual name and I can't figure out how to do it in a language-agnostic way. I understand that lazy-translation will be run when "when it is needed" so the only place, I could come up with and can actually access the choices is in <code>forms.py</code> where I tried like so:</p>
  
  <pre><code>  scope = forms.ChoiceField(
      required=True,
      label=_("Scope"),
      choices=sorted(settings.CATEGORIES.SCOPE_CHOICES, key=lambda x: x[1]),
      help_text=_("User participation scope.")
    )
  </code></pre>
  
  <p>because from there on it's displayed in the template:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    {{ form.scope.label_tag }}
    &lt;div class=""&gt;
      {{ form.scope.errors }}
      {{ form.scope }}
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Sadly it doesn't work and the items are still in the original order meaning not sorted alphabetically in any language I'm displaying them.</p>
  
  <p><strong>Question therefore</strong>:<br>
  How and where can I sort an array of Django lazy-translation-objects?</p>