You are here

private function JSqueeze::rsort in Advanced CSS/JS Aggregation 7.2

1 call to JSqueeze::rsort()
JSqueeze::renameVars in advagg_js_compress/jsqueeze.inc

File

advagg_js_compress/jsqueeze.inc, line 1114

Class

JSqueeze

Namespace

Patchwork

Code

private function rsort($array) {
  if (!$array) {
    return $array;
  }
  $i = 0;
  $tuples = array();
  foreach ($array as $k => &$v) {
    $tuples[] = array(
      ++$i,
      $k,
      &$v,
    );
  }
  usort($tuples, function ($a, $b) {
    if ($b[2] > $a[2]) {
      return 1;
    }
    if ($b[2] < $a[2]) {
      return -1;
    }
    if ($b[0] > $a[0]) {
      return -1;
    }
    if ($b[0] < $a[0]) {
      return 1;
    }
    return 0;
  });
  $array = array();
  foreach ($tuples as $t) {
    $array[$t[1]] =& $t[2];
  }
  return $array;
}