Made the interval sorting stable (second level sort by time_interval).
This is required so that intervals are sorted in the same way each time when going through pages of results.
This commit is contained in:
parent
3521e8d485
commit
eff341d832
|
@ -76,7 +76,15 @@ class WC_Admin_Reports_Data_Store {
|
||||||
// TODO: should return WP_Error here perhaps?
|
// TODO: should return WP_Error here perhaps?
|
||||||
}
|
}
|
||||||
if ( $a[ $this->order_by ] === $b[ $this->order_by ] ) {
|
if ( $a[ $this->order_by ] === $b[ $this->order_by ] ) {
|
||||||
return 0;
|
// 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 ] ) {
|
} elseif ( $a[ $this->order_by ] > $b[ $this->order_by ] ) {
|
||||||
return strtolower( $this->order ) === 'desc' ? -1 : 1;
|
return strtolower( $this->order ) === 'desc' ? -1 : 1;
|
||||||
} elseif ( $a[ $this->order_by ] < $b[ $this->order_by ] ) {
|
} elseif ( $a[ $this->order_by ] < $b[ $this->order_by ] ) {
|
||||||
|
|
Loading…
Reference in New Issue