Answer the question
In order to leave comments, you need to log in
How to make a specific entry appear first when sorting alphabetically?
In general, there is a method
public function getCountries()
{
$countries = ArrayHelper::map(Countries::find()
->orderBy(['name' => SORT_ASC])
->asArray()
->all(), 'id', 'name');
return $countries;
}
Answer the question
In order to leave comments, you need to log in
->orderBy([
new \yii\db\Expression('FIELD (id, 220)'),
'name' => SORT_ASC,
]);
....
unset($countries[220]);
$countries = [220 => 'Country Name'] + $countries;
return $countries;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question