Bring the thread to the interior of the knot and begin stitching the two pieces of cord together and building up stitches that will make contact with one side of the battery.
Then bury the thread tail by stitching it into the cord back the way it came (toward the looped end-- where you exit with the needle doesn't matter so much), then trim the tail.
Begin with a new thread and stitch from the center of the knot towards this marking.
If you accidentally mis-wire this section, it's easy to fix later by flipping one of the batteries, so don't worry! Tie a knot and bury the end of this thread back towards the center of the knot, then cut.