Sort on an array indexed value (cgridview)

I store a list of regions in an array and I store a region_id in the database.




public function getRegions()

{

	return array(

		1=>'North West',

		2=>'North East',

		3=>'South West',

		4=>'South East',

		5=>'West Midlands',

		6=>'East Midlands',

		7=>'London',

		8=>'Yorkshire',

		9=>'East England',

		10=>'Scotland',

		11=>'Wales',

		12=>'N. Ireland',

	);

}



I retrieve the region name as follows:




public function getEnquiryRegion()

{

	return $this->Regions[$this->region_id];

}



CGridView column:




array(

	'name'=>'region',

	'value'=>'$data->EnquiryRegion',

	'filter'=>$data->Regions,

),



But if I sort on the column then obviously it is just going to sort based on the numerical values, rather than the alphabatical values.

The only solutions I see are:

  • To store in db the table with regions

  • To rearrange the array in order to make so that the aphabetical order will correspond to the id order (if you can rearrange it, of corse).