Automattic\WooCommerce\Internal\Admin\ProductForm

Component::sort()public staticWC 1.0

Sorting function for product form component.

Метод класса: Component{}

Хуков нет.

Возвращает

int.

Использование

$result = Component::sort( $a, $b, $sort_by );
$a(Component) (обязательный)
Component a.
$b(Component) (обязательный)
Component b.
$sort_by(массив)
key and order to sort by.
По умолчанию: array()

Код Component::sort() WC 8.7.0

public static function sort( $a, $b, $sort_by = array() ) {
	$key   = $sort_by['key'];
	$a_val = $a->get_additional_argument( $key );
	$b_val = $b->get_additional_argument( $key );
	if ( 'asc' === $sort_by['order'] ) {
		return $a_val <=> $b_val;
	} else {
		return $b_val <=> $a_val;
	}
}