case insensitive sort

Hi all,

I am using CArrayDataProvider with CGridView, sort is working nicely, however, I have a problem on the sorting of the name. Why the sorting name is case sensitive, they display the capital letters first from A-Z then a-z? Can I make it case insensitive?




Same thing for me. But after spending hours looking for a way decided to surrender, at least for now.


I ended up with modifying "CArrayDataProvider.php" so the line 118 will be:

$column[$index]=is_object($data) ? strtolower( $data->$name ) : strtolower( $data[$name] );

In Yii 1.1.8, you can override CArrayDataProvider sortData function. I didn’t give it a rigorous workout , but seems to work fine for my application:

class myCArrayDataProvider extends CArrayDataProvider {

	public $casei = false;


	protected function sortData($directions)






		foreach($directions as $name=>$descending)



			foreach($this->rawData as $index=>$data)

				$column[$index]=is_object($data) ? $data->$name : $data[$name];




			$direction=$descending ? SORT_DESC : SORT_ASC;






		if ($this->casei) { 

			for ($i = 0; $i < count($args); $i++) {

				$args[$i] = (is_array($args[$i])) ? array_map('strtolower', $args[$i]) : $args[$i];





		call_user_func_array('array_multisort', $args);



Then when creating your dataProvider:

$dataProvider = new myCArrayDataProvider($proj_result, array(

  [rest of your params...]


$dataProvider->casei = true;

If you always wanted it case insensitive you could leave out the "casei" param.

Since 1.1.13, CArrayDataProvider allows for case insensitive sorting:

new CArrayDataProvider($translations, array(

            'keyField' => 'id',

            'caseSensitiveSort'=> false,



                    'language', 'message', 'translation', 'dealerVisible'



            'pagination' => array('pagesize' => 25)));