title: PHP - how to sort using usort by order of priority
body: <p>Hi all I have a xml object where I can get type based on index eg</p>
  <pre><code>(string)$this-&gt;xmlSimple-&gt;test[$i]-&gt;type
  </code></pre>
  <p>Type can be 2 values 'B', 'N' and B takes priority over N</p>
  <p>Currently I sort my expected array like so:</p>
  <pre><code>
  $sortedArray = [];
  $allowedTypes = [&quot;B&quot;, &quot;N&quot;];
  $count = $this-&gt;xmlSimple-&gt;test-&gt;count();
  
  foreach ($allowedTypes as $type) {
      for ($i = 0; $i &lt; $count; $i++) {
          if ((string)$this-&gt;xmlSimple-&gt;test[$i]-&gt;type == $type  {
              $sortedArray [] = $i;
          }
      }
  }
  
  </code></pre>
  <p>My question is how can achieve the same using sort or usort, so that it is sorted by B first and ordered index by B first and then type N</p>
  <p>Thanks</p>