Sort a list by integer with Elixir

Sort a list by integer with Elixir
  1. Fetch data from URL/li>
  2. Split each new line into a list item/li>
  3. Split each line into list items/li>
  4. Find the six digit video id from the URL, it should be the first integer in http paths of:
    “c13.adrise.tv/04C0BF/v2/sources/content-owners/”,
    “c13.adrise.tv/04C0BF/ads/transcodes/”
    /li>

  5. Group by Video ID/li>
  6. Get Cache Hit and Misses for each Video/li>
  7. Calculate the Cache Hit Misses
  8. Sort by video id
  import AccessLogApp.CLI, only: [
    ...
    sort_by_field: 2
  ]

  test "Sort by field name" do
    list = [
      %{:video_id => 9478, "TCP_hit_percentage" => "75%"},
      %{:video_id => 234567, "TCP_hit_percentage" => "100%"},
      %{:video_id => 9999, "TCP_hit_percentage" => "100%"},
      %{:video_id => 004567, "TCP_hit_percentage" => "100%"},
      %{:video_id => 123456, "TCP_hit_percentage" => "0%"},
      %{:video_id => 009899, "TCP_hit_percentage" => "100%"},
    ]
    result = sort_by_field(list, :video_id)
    assert result ==  [
      %{:video_id => 004567, "TCP_hit_percentage" => "100%"},
      %{:video_id => 9478, "TCP_hit_percentage" => "75%"},
      %{:video_id => 009899, "TCP_hit_percentage" => "100%"},
       %{:video_id => 9999, "TCP_hit_percentage" => "100%"},
      %{:video_id => 123456, "TCP_hit_percentage" => "0%"},
      %{:video_id => 234567, "TCP_hit_percentage" => "100%"}
    ]
  end
  def group_by_id(list) do
    Enum.group_by(list, fn [video_id, _] ->
      [video_id]
    end)
  end
sfgate Created with Sketch.

Made in San Francisco

Looking for an awesome web developer?