From cd1331bbc63cfb2c17632314e8111345b824d89d Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 7 Oct 2024 15:05:54 +0100 Subject: [PATCH] Sort formats by descending count in stats --- lib/music_library_web/controllers/stats_html.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/music_library_web/controllers/stats_html.ex b/lib/music_library_web/controllers/stats_html.ex index 1fcae19f..fd2d0f33 100644 --- a/lib/music_library_web/controllers/stats_html.ex +++ b/lib/music_library_web/controllers/stats_html.ex @@ -8,7 +8,9 @@ defmodule MusicLibraryWeb.StatsHTML do embed_templates "stats_html/*" defp format_records_count(records_count_by_format) do - Enum.map(records_count_by_format, fn {format, count} -> + records_count_by_format + |> Enum.sort_by(fn {_format, count} -> count end, :desc) + |> Enum.map(fn {format, count} -> Integer.to_string(count) <> " " <> Record.format_long_label(format) end) |> Enum.join(", ")