One way to do it is to tape the spokes together where they cross. Tape them before you take them off the old rim. Also mark the tape on the spokes that are either side of the stem hole. That way you can get them all plugged into the new rim, in the right order.
Just make sure you take off the tape before you start trying to true the new wheel.