I was having a look over some of my old work and saw that the asort function would have worked perfectly for some of the uses I needed, although I attempted an extremely different and longwinded way.
So my question is exactly, how does asort maintain association when sorting? I thought an array can be sorted by key, or by value, is there a third sorting pivot?
The "third pivot" is the actual location in memory/array.
You will see it clearly when doing a foreach on the following two arrays, which are the same, but have different order:
doing the default asort on those two arrays will result in both cases in: