An Issue with Karthiks Select 2 widget

[color=#222222][size=2]i have an issue with Karthiks Select 2 widget , when i choose lets say 3 lists, its reorder them randomly , how i can control ordering the items ?[/size][/color]

[color=#222222][size=2]this is my code[/size][/color]

[color=#222222][size=2]


<?php echo Select2::widget([

						'attribute' => 'country_id',

						'value' => '',

						'model' => $model,

						'data' =>ArrayHelper::map(Countries::find()->all(), 'id', 'name'),

						'options' => ['multiple' => true, 'placeholder' => '']

						]);


						?>

[/size][/color]

They are ordered in the order they were inserted into your db by default. You need to order your query. The second way allows you to sort by multiple columns and change the order.

[color="#222222"][size="2"]


Countries::find()->orderBy('name')->all();

or

Countries::find()->orderBy(['name'=>SORT_ASC])->all()

[/size][/color]

ok thanks