If you actually follow the movement of attached / unattached units in the army management screen the move from right to left and from bottom to top i.e. you have 40 rangers if which 32 are unattached and you want to find the attached units - with the grid being 1-40 and the majority of the attached units being replacements
Example - first attached unit is in position 33, you select this unit and the unit that was in position 34 moves up one space to position 33 (one space left and one row down) and position 40 is vacated
The units do not move randomly but to a set pattern
Furthermore, this topic has been suggested at least 5 times, please cross reference existing ideas and also please use the correct ideas template which can be found in the sticky threads at the top of the ideas section