Automattic\WooCommerce\Internal\Admin\ProductForm

Component::sortpublic staticWC 1.0

Sorting function for product form component.

Method of the class: Component{}

No Hooks.

Returns

Int.

Usage

$result = Component::sort( $a, $b, $sort_by );
$a(Component) (required)
Component a.
$b(Component) (required)
Component b.
$sort_by(array)
key and order to sort by.
Default: array()

Component::sort() code WC 10.9.4

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;
	}
}