Intersperse arguments and options w/ getopts

Is it possible to get a script that uses getopts to accept options and arguments in any order?

eg. -g -h 2 4 works like -g 2 -h 4.

check this link