WordPress at a glance
function is not described

_sort_nav_menu_items() WP 3.0.0

Deprecated from version 4.7.0. It is no longer supported and can be removed in future releases. Use wp_list_sort() instead.

Sort menu items by the desired key.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.

Return

Int. -1, 0, or 1 if $a is considered to be respectively less than, equal to, or greater than $b.

Usage

_sort_nav_menu_items( $a, $b );
$a(object) (required)
The first object to compare
$b(object) (required)
The second object to compare

Notes

  • Global. String. $_menu_item_sort_prop

Changelog

Since 3.0.0 Introduced.
Deprecated Since 4.7.0 Use wp_list_sort()

Code of _sort_nav_menu_items() WP 5.7

<?php
function _sort_nav_menu_items( $a, $b ) {
	global $_menu_item_sort_prop;

	_deprecated_function( __FUNCTION__, '4.7.0', 'wp_list_sort()' );

	if ( empty( $_menu_item_sort_prop ) )
		return 0;

	if ( ! isset( $a->$_menu_item_sort_prop ) || ! isset( $b->$_menu_item_sort_prop ) )
		return 0;

	$_a = (int) $a->$_menu_item_sort_prop;
	$_b = (int) $b->$_menu_item_sort_prop;

	if ( $a->$_menu_item_sort_prop == $b->$_menu_item_sort_prop )
		return 0;
	elseif ( $_a == $a->$_menu_item_sort_prop && $_b == $b->$_menu_item_sort_prop )
		return $_a < $_b ? -1 : 1;
	else
		return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
}