Automattic\WooCommerce\Internal\Admin\ProductForm
Component::sort
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() 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;
}
}