title: Sort array of arrays by a column with custom sorting priority (not alphabetically)
body: <p>Let's say I have this array:</p>
  
  <pre><code>$array = array(
      array("id" =&gt; 7867867, "animal" =&gt; "Dog"),
      array("id" =&gt; 3452342, "animal" =&gt; "Lion"),
      array("id" =&gt; 1231233, "animal" =&gt; "Lion"),
      array("id" =&gt; 5867867, "animal" =&gt; "Dog"),
      array("id" =&gt; 1111111, "animal" =&gt; "Zeebra"),
      array("id" =&gt; 2222222, "animal" =&gt; "Cat"),
      array("id" =&gt; 3333333, "animal" =&gt; "Cat"),
      array("id" =&gt; 4444444, "animal" =&gt; "Zeebra")
  );
  </code></pre>
  
  <p>Now what I've been trying to do is use php sort functions to be able to sort it based on specific rules (not alphabetical)</p>
  
  <p>The client wants this information sorted by "Lion first, Dog second, Zeebra third, Cat fourth".</p>
  
  <p>Something like this:</p>
  
  <pre><code>$array = array(
      array("id" =&gt; 3452342, "animal" =&gt; "Lion"),
      array("id" =&gt; 1231233, "animal" =&gt; "Lion"),
      array("id" =&gt; 7867867, "animal" =&gt; "Dog"),
      array("id" =&gt; 5867867, "animal" =&gt; "Dog"),
      array("id" =&gt; 4444444, "animal" =&gt; "Zeebra"),
      array("id" =&gt; 1111111, "animal" =&gt; "Zeebra"),
      array("id" =&gt; 2222222, "animal" =&gt; "Cat"),
      array("id" =&gt; 3333333, "animal" =&gt; "Cat"),
  );
  </code></pre>
  
  <p>The array would be sorted using the "animal" value and would be based on pre-determined rules.</p>
  
  <p>I was trying to figure out php sort functions but I could only get those to work with sorting the arrays alphabetically or numerically. </p>
  
  <p>What I've gotten to work is a block of if-statements and loops, and I would like to get rid of that slow code as soon as I can.</p>