Yii按关系列HAS_MANY排序

Business model:

One invoice can have can have multiple status (Draft, in progress, send, deleted).

In CGridView I want display invoices with last status

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'carriage-grid',
    'dataProvider'=>$model->search(array(
        'completed'=>true,
        'pagination'=>true,
    )),
    'filter'=>$model,
    'columns'=> [
        array(
        'name'=>'InvoiceName',
        'type'=>'raw',
        'value'=>$model->InvoiceName,
    ),
        array(
        'name' => 'InvoiceStatus',
        'value' => $model->InvoiceStatus->Name,
    ),
    ]
)); ?>

In invoice model I have declared relation:

'status'=>array(self::HAS_MANY, 'InvoiceStatus', 'invoice_id'),

In CGridView data displayed is correct, but when I try to order by InvoiceStatus->name

What I get:

(BY ASC)
  1. Invoice name + first status
  2. Invoice name 2 + first status

(BY DESC)

  1. Invoice name + last status
  2. Invoice name 2 + last status

What I expect to get:

(BY ASC)

  1. Invoice name + A status
  2. Invoice name 2 + B status

(BY DESC)

  1. Invoice name 2 + B status
  2. Invoice name 1 + A status

That mean, that I want order all record not only status, and always display last status