Title: _wp_object_count_sort_cb
Published: April 25, 2014
Last modified: April 28, 2025

---

# _wp_object_count_sort_cb( object $a, object $b ): int

## In this article

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

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_object_count_sort_cb/?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.

Serves as a callback for comparing objects based on count.

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

Used with `uasort()`.

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

 `$a`objectrequired

The first object to compare.

`$b`objectrequired

The second object to compare.

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

 int Negative number if `$a->count` is less than `$b->count`, zero if they are equal,
or greater than zero if `$a->count` is greater than `$b->count`.

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

    ```php
    function _wp_object_count_sort_cb( $a, $b ) {
    	return ( $a->count - $b->count );
    }
    ```

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

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_object_count_sort_cb/?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_wp_object_count_sort_cb%2F)
before being able to contribute a note or feedback.