title: How to sort an array of objects in PHP?
body: <p>Say I have a group of people, each person having a name, sex, and age property, coded like this:</p>
  
  <pre><code>public class Person
  {
     private $name, $sex, $age;
     public function Person ($name, $sex, $age)
     {
         $this-&gt;name = $name;
         $this-&gt;sex = $sex;
         $this-&gt;age = $age;
     }
     public function getName();    
     public function getSex();
     public function getAge();
  }
  
  public class People
  {
     private $people = array();
     public function addPerson ($name, $sex, $age)
     {
        $this-&gt;people[] = new Person($name, $sex, $age);
     }
  }
  </code></pre>
  
  <p>How could I implement a method <code>sortPeople()</code> which sorted the <code>$people</code> array in ascending order of the peoples' names to the <code>People</code> class?</p>