title: Sort array alphabetically in PHP
body: <p>I'm creating a website for a book publishing company. They've books in multiple different languages and want to display some details for each language. To retrieve all the necessary information for each language, I do the following:</p>
  
  <pre><code>  &lt;div class="col-lg-3" align="center"&gt;
          &lt;?php
              $fields = get_field_objects();                  
                  if ($fields):
                      foreach ($fields as $name =&gt; $field):    
                          if (stripos($name, 'isbn') !== false) : ?&gt;
                              &lt;?php $lang = substr($field['name'], strpos($field['name'], "_")); ?&gt;
                              &lt;div class="panel-group"&gt;
                                  &lt;div class="panel panel-default"&gt;
                                      &lt;div class="panel-heading"&gt;
                                          &lt;h4 class="panel-title"&gt;
                                              &lt;a data-toggle="collapse" href="#collapse1&lt;?php echo $lang ?&gt;"&gt;Deutsch/&lt;?php echo substr($field['label'], strpos($field['label'], " ") + 1); ?&gt;&lt;/a&gt;
                                          &lt;/h4&gt;
                                      &lt;/div&gt;
                                      &lt;div id="collapse1&lt;?php echo $lang ?&gt;" class="panel-collapse collapse"&gt;
                                          &lt;div class="panel-body"&gt;
                                        // ... get all neccessary information ...
                                         &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;?php endif;
                      endforeach;
                  endif; ?&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>Now my problem is, that if somebody creates a book, forgets to add a language and wants to add it after the book has been saved to the database, the alphabetical order is not correct anymore. 
  Therefore I'd like to add a sorting function for the $fields array. </p>
  
  <p>sort($fields) doesn't work since after doing this, everything is blank.</p>
  
  <p>Here's a screenshot of how the output looks like. 
  <a href="https://i.stack.imgur.com/7IKtM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7IKtM.png" alt="enter image description here"></a></p>
  
  <p>And sometimes, the order is wrong (e.g. Deutsch/English appears on the bottom). So I'll have to sort the part where I add the second language (next to German). The part where I add this is here:</p>
  
  <pre><code> &lt;h4 class="panel-title"&gt;
      &lt;a data-toggle="collapse" href="#collapse1&lt;?php echo $lang ?&gt;"&gt;Deutsch/&lt;?php echo substr($field['label'], strpos($field['label'], " ") + 1); ?&gt;&lt;/a&gt;
   &lt;/h4&gt;
  </code></pre>
  
  <p>Does anyone have any ideas? Please let me know if code is missing!</p>
  
  <p>P.S. the plugin I use is "Advanced-Custom-Fields" and the functions like e.g. "get_field_objects()" come with that plugin!</p>