Chtml:listdata With A Field Sort Parameter?

Hi,

Would it be possible to have a parameter included in this method for specifying the sort order of the array values? I think this would be pretty useful.

Hi,

The value returned is an array. You could use PHP’s array sorting functions for this purpose.

Are you having any special difficulties or facing corner cases?

Obrigado senhor.

No special difficulties but I was just wondering if it would be useful/cleaner to keep it all in one class method?

As you usually control the source of the data array, it shouldn’t pose a problem to control the source order in the first place. In case of active records, you could simply apply a scope or have the default sort order specified in the model’s defaultScope() method. So as far as I am concerned, this is really a non-issue. I tend to believe the Yii devs share that view :)

Yep, thinking about scopes etc, I think that’s a fair point. Thanks.

goes to add in scope to model

;D

Those scopes things work a treat haha ;D

Thanks!

You’re welcome ;)