title: Elixir Get Map containing maximum values of specific field
body: <p>I'm a beginner in Elixir programming language.</p>
  
  <p>I have an object something like this:</p>
  
  <pre><code>{
    id: uuid,
    created_at: DateTime.t,
    updated_at: DateTime.t,
    type: my_type
  }
  </code></pre>
  
  <p>let's say <code>my_type</code> is one of <code>~w[A B C D]</code></p>
  
  <p>I want to write a function which takes a list of these objects and returns a following map: </p>
  
  <pre><code>%{
    A: 120,
    B: 220,
    C: 560,
    D: 0,
    any: 560
  } 
  </code></pre>
  
  <p>The values here has to be the MAXIMUM difference between <code>updated_at</code> and <code>created_at</code> columns(<code>Timex.diff(updated_at, created_at, :seconds)</code>) per <code>my_type</code> + <code>any</code> in addition.
  In case of <code>any</code> the <code>my_type</code> is not considered and takes the maximum among all objects in the list.</p>
  
  <p>What is the best way to do it in Elixir? Thanks.</p>