'Find and sort the options
@param field: the Field
@param value: the currently selected value(s)'

def _options(self, field, value):

    options = self.options
    if (options is None):
        requires = field.requires
        if (not isinstance(requires, (list, tuple))):
            requires = [requires]
        if hasattr(requires[0], 'options'):
            options = requires[0].options()
        else:
            options = []
    elif isinstance(options, dict):
        options = options.items()
    none = self.none
    exclude = (('',) if (none is not None) else ('', None))
    options = [((s3_unicode(k) if (k is not None) else none), s3_unicode(v)) for (k, v) in options if (k not in exclude)]
    if (not options):
        return {'empty': current.T('no    options    available')}
    if (not isinstance(value, (list, tuple))):
        values = [value]
    else:
        values = value
    values = [s3_unicode(v) for v in values]
    helptext = {}
    help_field = self.help_field
    if help_field:
        if callable(help_field):
            help_field = help_field(options)
        if isinstance(help_field, dict):
            for key in help_field.keys():
                helptext[s3_unicode(key)] = help_field[key]
        else:
            (ktablename, pkey, multiple) = s3_get_foreign_key(field)
            if (ktablename is not None):
                ktable = current.s3db[ktablename]
                if hasattr(ktable, help_field):
                    keys = [k for (k, v) in options if k.isdigit()]
                    query = ktable[pkey].belongs(keys)
                    rows = current.db(query).select(ktable[pkey], ktable[help_field])
                    for row in rows:
                        helptext[unicode(row[pkey])] = row[help_field]
    _options = []
    oappend = _options.append
    for (k, v) in options:
        tooltip = helptext.get(k, None)
        item = (k, v, (k in values), tooltip)
        oappend(item)
    if self.sort:
        _options = sorted(_options, key=(lambda i: i[1].upper()[0]))
    return _options
