The end with the spring goes toward the engine, like it was when you removed it.
About the speedometer, I would remove the cable and try to insert the end that goes toward the trans. in the trans. speedometer gear and then see if you can turn the cable. If you can't then the speedometer gear is good and the cable may not be long enough to reach from inside the speedometer gear to the speedometer. This is just a guess, but if the speedometer registers when you unhook the cable from the trans. and spin it with your fingers and the cable will not turn when it is inserted in the trans. then I believe it is not long enough.
Good luck!