Problem/Motivation
There are several places in core where we need to sort an array by key, recursively (the recipe system has a usage of this, and a couple of tests do too) -- and there are instances in contrib where it's needed too (see #3550165: DefaultRelativeUrlPropSource does not sort properties keys for comparison, for example).
This would be useful for us to have generically.
Proposed resolution
Add a \Drupal\Component\Utility\SortArray::sortByKeyRecursive() method which does exactly what it says.
Issue fork drupal-3556987
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
penyaskitoYes please. Tagging need tests.
Comment #4
phenaproximaSmall unit test written.
Comment #5
fathershawnThat's a useful utility that consolidated several repetitions!
Comment #6
alexpottNice - law threes - time for it to become API.
Committed and pushed 5071f112783 to 11.x and 13d4f6c1a39 to 11.3.x. Thanks!
Comment #10
wim leersNice!
Canvas already has 3 copies of that function, and is about to gain a 4th in #3550165: DefaultRelativeUrlPropSource does not sort properties keys for comparison — nice to see this land in core so quickly! 🥳