Assuming that both lists are not sorted, you will need to loop through the second list once for each element in the first list, and the algorithm you used for this is correct; the only thing to do at the end is combine the list-of-lists. This combining will be more difficult if either of the two lists might contain a letter multiple times.
To make it faster, you could sort the lists, in which case you know when you’ve finished a certain letter. This could indeed be done using a third list that is being constructed as accumulator.
However, what probably would be better suited for your data, is to use a map instead of a list for List 2, as it seems to be a histogram.
Just curious if I changed from a two item tuple to stuct with like 5 or 6 properties then I would have to evaluate the whole struct as the “key”. Is there a way to go down to an individual property within the set ?
What you’re doing is still conceptually a mapping operation. Look at each Automobile, if the engine is special then return a modified rank, else pass through unchanged. You have a one-to-one relationship between input list and output list.
Thanks to both of you for the example and insight. This is exactly what I need and works great! Im still very new Elixir and need to become more familiar with the Maps and now MapSet