So I currently have this:
array(0=>'foo', 1=>'bar', 3=>'baz', 4=>'boo', 5=>'wahoo');
What I want is this:
array(0=>'foo', 3=>'baz', 1=>'bar', 5=>'wahoo', 4=>'boo');
This is a simplified example, my actual array is much larger and more complex so it can’t easily be broken into smaller pieces and re-assembled.
I’ve been using uksort to attempt this, which I think is the best way forward but can’t seem to get the results I want.
Edit:
I think my simplified example is actually confusing the issue. Here is my actual array and what I want to end up with.
Array
(
[1820] => Safety
[1821] => Security
[1822] => Digital Life
[1893] => Privacy and Digital Footprints
[1823] => Connected Culture
[1824] => Respecting Creative Work
[1825] => Searching
[1826] => Research and Evaluation
[1836] => Self-Expression and Identity
)
Array
(
[1820] => Safety
[1821] => Security
[1822] => Digital Life
[1893] => Privacy and Digital Footprints
[1823] => Connected Culture
[1836] => Self-Expression and Identity
[1824] => Respecting Creative Work
[1825] => Searching
[1826] => Research and Evaluation
)
So I almost have a numeric sort with two items pulled out of sequence.
New answer based on discussion.
Do use
uksort()Do a switch in the compare function for the ones that match and change them.
Example that works for your example above.