Please I need help with this Enum.max_by code snippet

This code snippet always returns the same item regardless of the item passed.

  def fuzzy_match(x, items) do
    m = Enum.max_by(items, fn i -> TheFuzz.compare(:jaro_winkler, x.desc, i.desc) end)
    IO.puts("fuzzy: #{inspect(m)}")
    m
  end

Please what have I missed?

What items do you pass in and what do you say the output should be for each?

Solved.

The first item in the list was blank, hence throwing off the results

1 Like

@OvermindDL1 the source data had blank strings in the desc. it would seems this throws off the fuzzy_match algorithm

1 Like