You are here

function smart_date_array_orderby in Smart Date 3.0.x

Same name and namespace in other branches
  1. 8.2 smart_date.module \smart_date_array_orderby()
  2. 3.x smart_date.module \smart_date_array_orderby()
  3. 3.1.x smart_date.module \smart_date_array_orderby()
  4. 3.2.x smart_date.module \smart_date_array_orderby()
  5. 3.3.x smart_date.module \smart_date_array_orderby()
  6. 3.4.x smart_date.module \smart_date_array_orderby()

Helper function to sort a multidimensional array on multiple values.

2 calls to smart_date_array_orderby()
SmartDateTrait::viewElements in src/SmartDateTrait.php
smart_date_recur_generate_rows in modules/smart_date_recur/smart_date_recur.module
Helper function to generate additional field deltas based on user inputs.

File

./smart_date.module, line 64
Field hooks for a field that stores a start and end date as timestamps.

Code

function smart_date_array_orderby() {
  $args = func_get_args();
  $data = array_shift($args);
  foreach ($args as $n => $field) {
    if (is_string($field)) {
      $tmp = [];
      foreach ($data as $key => $row) {
        $tmp[$key] = $row[$field];
      }
      $args[$n] = $tmp;
    }
  }
  $args[] =& $data;
  call_user_func_array('array_multisort', $args);
  return array_pop($args);
}