@classmethod
def _sorted_token_string_tuples(cls):
    """ Get a list of all search strings, and the tokens they represent, sorted longest
        to shortest by length.  This is required when tokenizing because some token strings
        are substrings of others.  The exact order of the tuples is not deterministic, but
        the rough order by length is expected to be sufficient.
        """
    ret = []
    for token in cls.valid_tokens():
        for token_str in token.strings:
            if not ret:
                ret.append((token_str, token))
                continue
            inserted = False
            for i in range(len(ret)):
                if len(token_str) > len(ret[i][0]):
                    ret.insert(i, (token_str, token))
                    inserted = True
                    break
            if not inserted:
                ret.append((token_str, token))
    return ret
