Hello. Can you please tell me if you can do the following?
I wanted to sort the articles by rating, the rating is calculated through this module https://github.com/hauntd/yii2-vote .
Something like this, only views is a field from a table with articles, and I need to sort by a field from a table with a rating:
<?php usort($competition, function ($a, $b) { return ($b['views'] - $a['views']); }) ?> <?php foreach ($competition as $item1): ?> ... Tied the model, tried it like this:
<?php usort($competition, function ($a, $b) { return ($b->aggregate['rating'] - $a->aggregate['rating']); }) ?> <?php foreach ($competition as $item1): ?> ... The order of the articles is changing, but not as much as we would like.
$bwith$asome places - teran