feat: allow advanced sorting of config schema sequences
1 unresolved thread
Closes #3298348
Merge request reports
Activity
Filter activity
added 1 commit
- d03bbbb1 - chore: additional comments around test cases
299 // https://www.drupal.org/project/drupal/issues/2855675 300 return $value; 301 } 302 $order_by = [$order_by]; 303 } 304 // Build an argument array for array_multisort(). 305 $args = []; 306 foreach ($order_by as $order) { 307 if (!is_array($order)) { 308 $order = [ 309 'sort_by' => $order, 310 ]; 311 } 312 $sort_array = []; 313 foreach ($value as $sequence_key => $sequence_element) { 314 $sort_array[$sequence_key] = NestedArray::getValue($sequence_element, explode(static::PROPERTY_SEPARATOR, $order['sort_by']), $key_exists); We can fall back to array_column() here if
!str_contains($order['sort_by'], static::PROPERTY_SEPARATOR)
, which I suspect will be the majority of cases. I wonder if there is value in adding a NestedArray::column() method to mimic array_column() for nested arrays that can fall back to array_column() when possible.Edited by Michael Lutz
Please register or sign in to reply