You are here

function tagadelic_sort_tags in Tagadelic 5

Same name and namespace in other branches
  1. 6 tagadelic.module \tagadelic_sort_tags()
  2. 7 tagadelic.module \tagadelic_sort_tags()

API funtion to order a set of tags. @todo If you feel like making this more modular, please send me patches.

3 calls to tagadelic_sort_tags()
tagadelic_block in ./tagadelic.module
implementation of hook_block
tagadelic_page_chunk in ./tagadelic.module
menu callback renders a tagadelic page
tagadelic_page_list in ./tagadelic.module
menu callback renders a tagadelic page with listed items: each voc

File

./tagadelic.module, line 265

Code

function tagadelic_sort_tags($tags) {
  list($sort, $order) = explode(',', variable_get('tagadelic_sort_order', 'title,asc'));
  switch ($sort) {
    case 'title':
      usort($tags, "_tagadelic_sort_by_title");
      break;
    case 'weight':
      usort($tags, "_tagadelic_sort_by_weight");
      break;
    case 'random':
      shuffle($tags);
      break;
  }
  if ($order == 'desc') {
    $tags = array_reverse($tags);
  }
  return $tags;
}