function tagclouds_sort_tags in TagCloud 7
API function to order a set of tags.
$Sort = NULL, "title, asc", "title, desc", "count, asc", "count, desc" @todo If you feel like making this more modular, please send me patches.
3 calls to tagclouds_sort_tags()
- tagclouds_block_view in ./
tagclouds.module - Implements hook_block_view().
- tagclouds_page_chunk in ./
tagclouds.module - Menu callback renders a tagclouds page.
- tagclouds_page_list in ./
tagclouds.module - Menu callback renders a tagclouds page with listed items: each vocabulary.
File
- ./
tagclouds.module, line 354
Code
function tagclouds_sort_tags($tags, $sort = NULL) {
if ($sort == NULL) {
$sort = 'title,asc';
list($sort, $order) = explode(',', variable_get('tagclouds_sort_order', $sort));
}
else {
list($sort, $order) = explode(',', $sort);
}
switch ($sort) {
case 'title':
usort($tags, "_tagclouds_sort_by_title");
break;
case 'count':
usort($tags, "_tagclouds_sort_by_count");
break;
case 'random':
shuffle($tags);
break;
}
if ($order == 'desc') {
$tags = array_reverse($tags);
}
return $tags;
}