- // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
- if ( 'name' == $orderby )
- uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );
- else
- uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
-
- $tags = apply_filters( 'tag_cloud_sort', $tags, $args );
-
- if ( 'DESC' == $order )
- $tags = array_reverse( $tags, true );
- elseif ( 'RAND' == $order ) {
- $keys = (array) array_rand( $tags, count( $tags ) );
- $temp = array();
- foreach ( $keys as $key )
- $temp[$key] = $tags[$key];
+ $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );
+ if ( $tags_sorted != $tags ) { // the tags have been sorted by a plugin
+ $tags = $tags_sorted;
+ unset($tags_sorted);
+ } else {
+ if ( 'RAND' == $order ) {
+ shuffle($tags);
+ } else {
+ // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
+ if ( 'name' == $orderby )
+ uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );
+ else
+ uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );