get_dimension_options -> get_dimension_options_n

get_dimension_options is just a special case of get_dimension_options_n;
merging them so we only write the output lookup and sorting code once.
order dimension_options by their sort order
also sort grouped dimension options
Merge branch 'sort-options'