Created
August 30, 2013 00:19
-
-
Save clifgriffin/6384966 to your computer and use it in GitHub Desktop.
Sort get_terms, naturally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sort_terms ( $terms ) { | |
$sort_terms = array(); | |
foreach($terms as $term) { | |
$sort_terms[$term->name] = $term; | |
} | |
uksort( $sort_terms, 'strnatcmp'); | |
return $sort_terms; | |
} | |
// Usage | |
$terms = get_terms('tags'); | |
$terms = sort_terms($terms); // that was easy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment