Sort function for Activities in CaseView
I think my mistake was using the functions array_push and array_merge, as they assigned new keys to the array elements (activity types). Therefore, the single activity types couldn't be found in the following code anymore.
I changed these two expressions to:
$new_array[$key] = $aTypes[$key]; /// instead of: array_push($new_array, $aTypes[$key]);

and
$new_array = $new_array + $aTypes; /// instead of: $new_array = array_merge($new_array, $aTypes);

With that, it seems to work now.