I had the same Problem with 2 Audiointerfaces and "friendly names".
Windows assigns the usb-ports as devices #0 #1 #2 ...in RANDOM order.
But the midi-devices "without friendly names" are in perfect order, no matter when I turn them on and off.
Sonar remembers all midi in and out to the correcht synths.
All tracks are designed to the correct synth, even when the power of the synth is turned off.