The district court having jurisdiction may, subject to the requirements of this part 9, in lieu of the sentence otherwise provided by law, commit a sex offender to the custody of the department for an indeterminate term having a minimum of one day and a maximum of his or her natural life.