Where did the term 'dress to the nines' come from?

The term "dress to the nines" comes from England when sailing ships were used. As the ship would come into the harbor all sails would be flying, all nine of them. And all the sailors would be dressed in dress uniforms lined up on either side of the ship. The modern connotation is to have put on your finest clothing and jewelry, almost as if you were being visited by royalty. See also 'putting on the dog.'