original_string: public static function groupElementsByValueKeys($array, $groupKeys) {
  
          if (!is_array($groupKeys)) {
              $groupKeys = array($groupKeys);
          }
  
          $newArray = new AssociativeArray();
          foreach ($array as $element) {
  
              $applyObject = $newArray;
              foreach ($groupKeys as $index => $groupKey) {
                  if ($index < sizeof($groupKeys) - 1) {
                      $subArray = $applyObject[$element[$groupKeys[$index]]];
                      if (!$subArray) {
                          $subArray = new AssociativeArray();
                          $applyObject[$element[$groupKeys[$index]]] = $subArray;
                      }
                      $applyObject = $subArray;
                  } else {
                      if (!is_array($applyObject[$element[$groupKeys[$index]]])) {
                          $applyObject[$element[$groupKeys[$index]]] = array();
                      }
                      $applyObject[$element[$groupKeys[$index]]][] = $element;
  
                  }
              }
  
          }
  
          
          return $newArray->toArray();
      }
code: public static function groupElementsByValueKeys($array, $groupKeys) {
  
          if (!is_array($groupKeys)) {
              $groupKeys = array($groupKeys);
          }
  
          $newArray = new AssociativeArray();
          foreach ($array as $element) {
  
              $applyObject = $newArray;
              foreach ($groupKeys as $index => $groupKey) {
                  if ($index < sizeof($groupKeys) - 1) {
                      $subArray = $applyObject[$element[$groupKeys[$index]]];
                      if (!$subArray) {
                          $subArray = new AssociativeArray();
                          $applyObject[$element[$groupKeys[$index]]] = $subArray;
                      }
                      $applyObject = $subArray;
                  } else {
                      if (!is_array($applyObject[$element[$groupKeys[$index]]])) {
                          $applyObject[$element[$groupKeys[$index]]] = array();
                      }
                      $applyObject[$element[$groupKeys[$index]]][] = $element;
  
                  }
              }
  
          }
  
          
          return $newArray->toArray();
      }
code_tokens: public static function groupElementsByValueKeys ( $ array , $ groupKeys ) { if ( ! is_array ( $ groupKeys ) ) { $ groupKeys = array ( $ groupKeys ) ; } $ newArray = new AssociativeArray ( ) ; foreach ( $ array as $ element ) { $ applyObject = $ newArray ; foreach ( $ groupKeys as $ index => $ groupKey ) { if ( $ index < sizeof ( $ groupKeys ) - 1 ) { $ subArray = $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] ; if ( ! $ subArray ) { $ subArray = new AssociativeArray ( ) ; $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] = $ subArray ; } $ applyObject = $ subArray ; } else { if ( ! is_array ( $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] ) ) { $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] = array ( ) ; } $ applyObject [ $ element [ $ groupKeys [ $ index ] ] ] [ ] = $ element ; } } } return $ newArray -> toArray ( ) ; }
docstring: Group an array of elements by one or more of it's keys.  Essentially convert into an indexed array for each key type.
  
  @param $array
  @param $groupKeys
docstring_tokens: Group an array of elements by one or more of it s keys . Essentially convert into an indexed array for each key type .