private function getSortedMediaTypeList(int $tot): array
    {
        $media = [];
        $c     = 0;
        $max   = 0;

        foreach (self::MEDIA_TYPES as $type) {
            $count = $this->totalMediaTypeQuery($type);

            if ($count > 0) {
                $media[$type] = $count;

                if ($count > $max) {
                    $max = $count;
                }

                $c += $count;
            }
        }

        $count = $this->totalMediaTypeQuery(self::MEDIA_TYPE_UNKNOWN);
        if ($count > 0) {
            $media[self::MEDIA_TYPE_UNKNOWN] = $tot - $c;
            if ($tot - $c > $max) {
                $max = $count;
            }
        }

        if (count($media) > 10 && ($max / $tot) > 0.6) {
            arsort($media);
            $media = array_slice($media, 0, 10);
            $c     = $tot;

            foreach ($media as $cm) {
                $c -= $cm;
            }

            if (isset($media[self::MEDIA_TYPE_OTHER])) {
                $media[self::MEDIA_TYPE_OTHER] += $c;
            } else {
                $media[self::MEDIA_TYPE_OTHER] = $c;
            }
        }

        asort($media);

        return $media;
    }