Fixed counting occurences of numeric keys

This commit is contained in:
Marcin Kurczewski 2013-10-14 09:51:38 +02:00
parent 23fc89c30c
commit c6cdc1d945

View file

@ -16,19 +16,16 @@ class TagController
$dbQuery->innerJoin('post_tag');
$dbQuery->on('tag.id = post_tag.tag_id');
$dbQuery->groupBy('tag.id');
$dbQuery->orderBy('count desc, LOWER(tag.name) asc');
$rows = $dbQuery->get();
$tags = [];
$tagDistribution = [];
foreach ($rows as $row)
{
$tags []= $row['name'];
$tagDistribution[$row['name']] = $row['count'];
$tags []= strval($row['name']);
$tagDistribution[$row['name']] = intval($row['count']);
}
array_multisort(
array_values($tagDistribution), SORT_DESC, SORT_NUMERIC,
array_keys($tagDistribution), SORT_ASC, SORT_NATURAL | SORT_FLAG_CASE,
$tagDistribution);
$this->context->transport->tags = $tags;
$this->context->transport->tagDistribution = $tagDistribution;