Skip to content

Instantly share code, notes, and snippets.

@clifgriffin
Created August 30, 2013 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clifgriffin/6384966 to your computer and use it in GitHub Desktop.
Save clifgriffin/6384966 to your computer and use it in GitHub Desktop.
Sort get_terms, naturally
<?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