'Helper method to finalize an options group, render its label
and sort the options
@param group: the group as dict {letters: [], items: []}
@param values: the currently selected values as list
@param helptext: dict of {key: helptext} for the options'

@staticmethod
def _close_group(group, values, helptext, sort=True):

    group_letters = group['letters']
    if group_letters:
        if (len(group_letters) > 1):
            group['label'] = ('%s    -    %s' % (group_letters[0], group_letters[(-1)]))
        else:
            group['label'] = group_letters[0]
    else:
        group['label'] = None
    del group['letters']
    if sort:
        group_items = sorted(group['items'], key=(lambda i: (i[1].upper()[0] if i[1] else None)))
    else:
        group_items = group['items']
    items = []
    T = current.T
    for (key, label) in group_items:
        tooltip = helptext.get(key)
        if tooltip:
            tooltip = s3_str(T(tooltip))
        item = (key, label, (key in values), tooltip)
        items.append(item)
    group['items'] = items
    return
