My problem is slightly similar to: Sort an Array by keys based on another Array?
I have a nested associative array of file paths and directories, here is an example:
Array
(
[Introduction] => /documentation/Introduction.md
[Preface] => Array
(
[Installation] => /documentation/Preface/Installation.md
[Requirements] => /documentation/Preface/Requirements.md
)
)
If any value is an array, this represents a sub-directory, and if it's a string, it's a filepath. This is used to output a bulletpointed navigation list of documentation articles. The documentation articles are stored in markdown files.
THE PROBLEM:
The array is currently in alphabetical order. I want to store another array of filepaths and directories within the application containing the intended order, and I want a function to attempt to re-order the filepaths array above to match the order of the array stored in the application. If someone adds any new documentation articles to the file system, but doesn't add it to the order array, then that article needs to be placed at the bottom of the array for that directory.
So for example, if someone were to add a documentation article at /documentation/Preface/Release Notes.md
, it would be added to the bottom of the Preface sub-array if it isn't specified in the order array. If it is specified in the order array, then it should appear wherever intended.