I have an array in this way
{
1="Металлургия и производство готовых металлических продуктов",
2="Химическая промышленность",
3="Альтернативная энергетика",
4="Транспортная инфраструктура"
}
I've looked another questions like this, but couldn't find anything.
Full code:
$.getJSON('/project/'+ clicked +'s/', function(data) {
var info =
'<td></td>'
+'<td>'
+'<select name="'+ clicked +'_id'+ id +'" id="edit_'+ clicked +'_id'+ id +'">'
+'<option value="">'+obj['list_'+lang]+'</option>';
for (var i in data) {
info += '<option value="'+ i +'">'+ data[i] +'</option>';
}
info += '</select>'
+'</td>';
$('#'+ clicked +'s'+ id).show().html(info);
});
In data I have an array which is above. I want to sort them alphabetically like this: 3="Альтернативная энергетика" 1="Металлургия и производство готовых металлических продуктов"
class Controller_Project extends Controller_Website {
public function action_sectors() {
$sectors = ORM::factory('sector')
->find_all()
->as_array('id', 'name');
$ar_sectors = array();
switch ($this->user_language) {
case 'ru':
$ar_sectors[15] = 'Агропромышленный комплекс';
$ar_sectors[3] = 'Альтернативная энергетика';
$ar_sectors[7] = 'АПК и текстильная промышленность';
$ar_sectors[13] = 'Атомная промышленность и атомная энергетика';
break;
case 'en':
$ar_sectors[15] = 'Agricultural Sector';
$ar_sectors[3] = 'Alternative Energy Industry';
$ar_sectors[7] = 'Agriculture and textiles';
$ar_sectors[13] = 'Atomic Industry';
break;
}
$sectors = $ar_sectors;
$this->auto_render = FALSE;
$this->request->response = json_encode($sectors);
}
}
The site where code is situated http://new.baseinvest.kz/project