Sort the tag in the cloud

@param \Jb\Bundle\TagCloudBundle\Model\TagCloud $cloud
180839
public function process(\Jb\Bundle\TagCloudBundle\Model\TagCloud $cloud)
    {
        $keys = array_keys($cloud->getTags());
        asort($keys);

        $new = array();
        $old = $cloud->getTags();

        foreach($keys as $key) {
            $new[$key] = $old[$key];
        }

        $cloud->setTags($new);
    }
28780
public function tag($tag)
    {
        $blogs = $this->repository->tags($tag);
        $tags = $this->repository->allTags();

        if (empty($blogs)) {
            abort(404);
        }

        return view('cms-frontend::blog.all')
            ->with('tags', $tags)
            ->with('blogs', $blogs);
    }
188739
public function setCluster($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Cluster::class);
        $this->cluster = $var;

        return $this;
    }
1373247
public function removeTag(Tag $tag)
    {
        if ($this->tags->contains($tag)) {
            $this->tags->removeElement($tag);
            return true;
        }
        return false;
    }
285123
public function sort($flags = SORT_REGULAR)
    {
        $this->_modified = true;
        return sort($this->_storage, $flags);
    }
366887
public function iShouldSeeOnTheTagCloudThatThereAreBlogPostsTaggedWith($term, $count)
    {
        $xpath = sprintf('//ul[contains(@class, "tag-cloud")]//li/a[contains(., "%s")]', $term);
        $node = $this->getSession()->getPage()->find('xpath', $xpath);

        if (is_null($node)) {
            throw new ElementNotFoundException($this->getSession(), 'Tag');
        }

        $tagTitle = $node->getAttribute('title');
        $title = sprintf('%d posts tagged with %s', $count, $term);

        if ($title != $tagTitle) {
            throw new ExpectationException(sprintf('Expected "%s" but found: "%s"', $title, $tagTitle), $this->getSession());
        }
    }
757334
public function addTag(Tag $tag)
    {
        $tag->setBlog($this);
        $this->tags->add($tag);

        return $tag;
    }
321506
protected function sort()
    {
        if (!$this->sorted) {
            uasort($this->items, [$this, 'compare']);
            $this->sorted = true;
        }
    }
46148
public function sort($sort_flags = SORT_REGULAR)
        {
            $array = $this->get();
            sort($array, $sort_flags);
            $this->update($array);
            return $this;
        }
354672
public function setCloudStoragePath($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudStoragePath::class);
        $this->writeOneof(3, $var);

        return $this;
    }
439508
def sort_tags_by_date(tags)
      puts "Sorting tags..." if options[:verbose]
      tags.sort_by! do |x|
        get_time_of_tag(x)
      end.reverse!
    end
113748
protected function processTags()
	{
		if (empty($this->tagStack))
		{
			return;
		}

		// Initialize the count tables
		foreach (array_keys($this->tagsConfig) as $tagName)
		{
			$this->cntOpen[$tagName]  = 0;
			$this->cntTotal[$tagName] = 0;
		}

		// Process the tag stack, close tags that were left open and repeat until done
		do
		{
			while (!empty($this->tagStack))
			{
				if (!$this->tagStackIsSorted)
				{
					$this->sortTags();
				}

				$this->currentTag = array_pop($this->tagStack);
				$this->processCurrentTag();
			}

			// Close tags that were left open
			foreach ($this->openTags as $startTag)
			{
				// NOTE: we add tags in hierarchical order (ancestors to descendants) but since
				//       the stack is processed in LIFO order, it means that tags get closed in
				//       the correct order, from descendants to ancestors
				$this->addMagicEndTag($startTag, $this->textLen);
			}
		}
		while (!empty($this->tagStack));
	}
731978
public function sort($order = 'asc')
    {
        if ($order == 'desc') {
            rsort($this->_map);
        }else{
            sort($this->_map);
        }

        return $this;
    }
818553
def calculate_tag_cloud(num = 5)
      range = 0

      tags = active_tags.map { |tag, posts|
        [tag.to_s, range < (size = posts.size) ? range = size : size]
      }

      range = 1..range

      tags.sort!.map! { |tag, size| [tag, range.quantile(size, num)] }
    end
593256
public static function addOrderSort($sort, $table, &$query)
    {
        if (!empty($sort)) {
            $sorts = explode(',', $sort);
            foreach ($sorts as $sort) {
                if (!strpos($sort, '.')) {
                    preg_match('/\w+\s+(DESC|ASC)/', $sort, $sort_field);
                    $type = !empty($sort_field) ? trim($sort_field[1]) : 'DESC';
                    $field = !empty($sort_field) ? trim(substr($sort, 0, -strlen($type))) : trim($sort);
                    $order[$table . '.' . $field] = $type == 'DESC' ? SORT_DESC : SORT_ASC;
                } else {
                    $sort_table = trim(substr($sort, 0, strrpos($sort, '.')));
                    preg_match('/\w+\.\w+\s+(DESC|ASC)/', $sort, $sort_field);
                    $type = trim($sort_field[1]);
                    $field = trim(substr(substr($sort, strrpos($sort, '.') + 1), 0, -strlen($type)));
                    $order[trim($sort_table) . '.' . $field] = $type == 'DESC' ? SORT_DESC : SORT_ASC;;
                    $query->select[] = explode(' ', $sort_field[0])[0];
                    $query->joinWith($sort_table);
                }
            }
            $query->select[] = $table . ".*";
        }
        $query->orderBy($order);
    }
552267
public static function cloud_sort($a, $b) {
        $tagsort = self::$cloudsortfield ?: 'name';

        if (is_numeric($a->$tagsort)) {
            return ($a->$tagsort == $b->$tagsort) ? 0 : ($a->$tagsort > $b->$tagsort) ? 1 : -1;
        } else if (is_string($a->$tagsort)) {
            return strcmp($a->$tagsort, $b->$tagsort);
        } else {
            return 0;
        }
    }
1075652
public function setCloud($cloud)
    {
        if ($cloud instanceof FeedCloud) {
            $this->cloud = $cloud;
        } elseif (is_array($cloud)) {
            if (!empty($cloud)) {
                $this->cloud = FeedCloud::createFromArray($cloud);
            }
        } elseif (is_null($cloud)) {
            $this->cloud = null;
        } else {
            throw new \InvalidArgumentException('Invalid cloud');
        }

        return $this;
    }