Title: WP_Theme::_name_sort
Published: April 25, 2014
Last modified: April 28, 2025

---

# WP_Theme::_name_sort( WP_Theme $a, WP_Theme $b ): int

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Callback function for usort() to naturally sort themes by name.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#description)󠁿

Accesses the Name header directly from the class for maximum speed.
Would choke 
on HTML but we don’t care enough to slow it down with strip_tags().

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#parameters)󠁿

 `$a`[WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/)required

First theme.

`$b`[WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/)required

Second theme.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#return)󠁿

 int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall
equally.
 Greater than 0 if `$a` falls higher in the natural order than `$b`. Used
with usort().

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#source)󠁿

    ```php
    private static function _name_sort( $a, $b ) {
    	return strnatcasecmp( $a->headers['Name'], $b->headers['Name'] );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-theme.php#L2141)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-theme.php#L2141-L2143)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_theme/_name_sort/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme%2F_name_sort%2F)
before being able to contribute a note or feedback.