with Midwest last in both cases, which shouldn't happen, since M comes before N
Actually, M and N does not matter. What matters is the second character. However, Midwest should still come first, since i is before o. I tested with:
<?php
$region = array("Midwest", "Northeast", "Southeast", "Southwest", "Northwest", "NonContig");
usort($region, create_function('$a, $b', 'strcmp($a[1], $b[1]);'));
echo implode(', ', $region);
?>
The result was incorrect:
Northwest, NonContig, Southwest, Southeast, Northeast, Midwest
Then I tested with:
<?php
function cmp($a, $b) {
return strcmp($a[1], $b[1]);
}
$region = array("Midwest", "Northeast", "Southeast", "Southwest", "Northwest", "NonContig");
usort($region, 'cmp');
echo implode(', ', $region);
?>
The result was now correct:
Midwest, NonContig, Northwest, Southeast, Northeast, Southwest
Either both NogDog and I are doing something wrong, or we have just discovered a bug with PHP 5.2.1's version of create_function().