2

How can i sort an Array like this:

So this works:

ArrayHelper::multisort($dataProvider, ['id'], [SORT_DESC]);


foreach ($dataProvider as $teilnahme) {
    ?>
<tr><td><?= Html::a("<time>". Yii::$app->formatter->asDate($teilnahme->durchfuehrung0->datum)."</time>", ['/durchfuehrung/detail/'.$teilnahme->durchfuehrung0->id], ['class'=>'']) ?>

    </td>
    <td><?= Html::a($teilnahme->durchfuehrung0->veranstalter0->name, ['/veranstalter/profil/'.$teilnahme->durchfuehrung0->veranstalter0->id], ['class'=>'']) ?>

    </td>
    <td>
        <?= $teilnahme->durchfuehrung0->veranstalter0->region0->name; ?>
    </td>
    <td>
        <?= $teilnahme->punkte; ?>
    </td>
</tr>
<?php

But how can i Sort:

$teilnahme->durchfuehrung0->datum

What i tried:

ArrayHelper::multisort($dataProvider,function($item){
    return isset($item->durchfuehrung0['datum']) ? ['id', 'datum'] : 'datum';
},SORT_DESC);

but nothing happens here....

2
  • How can i delete my stupid Question Commented May 5, 2017 at 9:41
  • This is the Solution: Very simpleusort($dataProvider, function($a, $b) { return strcmp($b->durchfuehrung0->datum, $a->durchfuehrung0->datum); }); Commented May 5, 2017 at 9:41

1 Answer 1

3

I tried to find a solution to sort dropDownList with ArrayHelper::map.

This is the solution I got for my project:

dropDownList(ArrayHelper::map(tab_sectors::find()->asArray()->select('Id, Description')->orderBy('Description')->all(), 'Id','Description')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.