You are here

protected function RestfulDataProviderCToolsPlugins::sortMultiCompare in RESTful 7

Sort plugins by multiple criteria.

@link http://stackoverflow.com/a/13673568/750039

Parameters

$value1: The first value.

$value2: The second value.

Return value

int The values expected by uasort() function.

File

plugins/restful/RestfulDataProviderCToolsPlugins.php, line 187
Contains \RestfulDataProviderCToolsPlugins

Class

RestfulDataProviderCToolsPlugins
@file Contains \RestfulDataProviderCToolsPlugins

Code

protected function sortMultiCompare($value1, $value2) {
  $sorts = $this
    ->parseRequestForListSort();
  foreach ($sorts as $key => $order) {
    if ($value1[$key] == $value2[$key]) {
      continue;
    }
    return ($order == 'DESC' ? -1 : 1) * strcmp($value1[$key], $value2[$key]);
  }
  return 0;
}