def fuzzy_search(query, elements, key=(lambda x: x), rank=True, seq=3):
 R = match_rank(query, [key(el) for el in elements], seq=seq)
 out = [(el, R[i]) for (i, el) in enumerate(elements) if (R[i] is not None)]
 return [el[0] for el in sorted(out, key=(lambda el: el[1]))]

def fuzzy_search ( query , elements , key = ( lambda x : x ) , rank = True , seq = 3 ) : R = match_rank ( query , [ key ( el ) for el in elements ] , seq = seq ) out = [ ( el , R [ i ] ) for ( i , el ) in enumerate ( elements ) if ( R [ i ] is not None ) ] return [ el [ 0 ] for el in sorted ( out , key = ( lambda el : el [ 1 ] ) ) ]
fuzzy search for query in list of strings .