If, in any action, judgment upon motion to dismiss by either party to the action is given against the plaintiff, the defendant shall recover costs against the plaintiff; if such judgment is given for the plaintiff, he shall recover costs against the defendant.
C.R.S. § 13-16-107