Title: _sort_name_callback
Published: April 25, 2014
Last modified: February 24, 2026

---

# _sort_name_callback( array $a, array $b ): int

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_sort_name_callback/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_sort_name_callback/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_sort_name_callback/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/functions/_sort_name_callback/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_sort_name_callback/?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 to sort array by a ‘name’ key.

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

 `$a`arrayrequired

First array.

`$b`arrayrequired

Second array.

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

 int

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

    ```php
    function _sort_name_callback( $a, $b ) {
    	return strnatcasecmp( $a['name'], $b['name'] );
    }
    ```

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

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

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

## User Contributed Notes

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