WordPress at a glance
function is not described

Automattic\WooCommerce\Admin\API\Reports

DataStore::interval_cmp() private WC 1.0

Compares two report data objects by pre-defined object property and ASC/DESC ordering.

{} It's a method of the class: DataStore{}

No Hooks.

Return

String. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->interval_cmp( $a, $b );
$a(stdClass) (required)
Object a.
$b(stdClass) (required)
Object b.

Code of DataStore::interval_cmp() WC 5.2.2

<?php
private function interval_cmp( $a, $b ) {
	if ( '' === $this->order_by || '' === $this->order ) {
		return 0;
		// @todo Should return WP_Error here perhaps?
	}
	if ( $a[ $this->order_by ] === $b[ $this->order_by ] ) {
		// As relative order is undefined in case of equality in usort, second-level sorting by date needs to be enforced
		// so that paging is stable.
		if ( $a['time_interval'] === $b['time_interval'] ) {
			return 0; // This should never happen.
		} elseif ( $a['time_interval'] > $b['time_interval'] ) {
			return 1;
		} elseif ( $a['time_interval'] < $b['time_interval'] ) {
			return -1;
		}
	} elseif ( $a[ $this->order_by ] > $b[ $this->order_by ] ) {
		return strtolower( $this->order ) === 'desc' ? -1 : 1;
	} elseif ( $a[ $this->order_by ] < $b[ $this->order_by ] ) {
		return strtolower( $this->order ) === 'desc' ? 1 : -1;
	}
}