<p>So I build an array of various dates. Birthdays, anniversaries, and holidays. I'd like to order the array by which one is happening next, essentially sort October to September (wrapping to next year)</p>

<p>so if my array is </p>

<pre><code>$a = ([0]=&gt;"1980-04-14", [1]=&gt;"2007-06-08", 
  [2]=&gt;"2008-12-25", [3]=&gt;"1978-11-03")
</code></pre>

<p>I'd like to sort it so it is arranged</p>

<pre><code>$a = ([0]=&gt;"1978-11-03", [1]=&gt;"2008-12-25", 
  [2]=&gt;"1980-04-14", [3]=&gt;"2007-06-08")
</code></pre>

<p>because the november 'event' is the one that will happen next (based on it being october right now).</p>

<p>I'm trying usort where my cmp function is </p>

<pre><code>function cmp($a, $b)
{
  $a_tmp = split("-", $a);
  $b_tmp = split("-", $b);
  return strcmp($a_tmp[1], $b_tmp[1]);
} 
</code></pre>

<p>I am not sure how to modify this to get my desired effect.</p>

Don't compare strings, instead use seconds since 1970 (ints):
```
```
$date1 = split("-", $a);
$date2 = split("-", $b);
$seconds1 = mktime(0,0,0,$date1[1],$date1[2],$date1[0]);
$seconds2 = mktime(0,0,0,$date2[1],$date2[2],$date2[0]);
// eliminate years
$seconds1 %= 31536000;
$seconds2 %= 31536000;
return $seconds1 - $seconds2;
```
```
Also I don't know PHP but I think the gist is correct.
Edit: The comparison function is encapsulated to perform comparison, nothing more.  To order a list in regards to the original question sort an array with today's date included, locate today's date in the array, and then move the elements before that position to the end in ascending order by position.