public function sort($cmpFunction)
{
// we do not use $this->uasort as we do not want to maintain keys
$tables = $this->getTables();
// we need to make sure first table always comes first, only sort tables after the first table
$firstTable = array_shift($tables);
usort($tables, function ($ta, $tb) use($tables, $cmpFunction) {
$return = call_user_func($cmpFunction, $ta, $tb);
if ($return === 0) {
$indexA = array_search($ta, $tables);
$indexB = array_search($tb, $tables);
return $indexA - $indexB;
}
return $return;
});
array_unshift($tables, $firstTable);
$this->exchangeArray($tables);
}