if ($a['weight'] < $b['weight']) return -1;
if ($a['weight'] > $b['weight']) return 1;
// fallback to name sort; don't really want to do this, but it makes results more stable
if ($a['weight'] < $b['weight']) return -1;
if ($a['weight'] > $b['weight']) return 1;
// fallback to name sort; don't really want to do this, but it makes results more stable