From: Felipe Contreras Date: Fri, 19 Apr 2013 19:30:30 GMT Subject: [PATCH v3 10/11] contrib: cc-cmd: sort by participation Message-ID: <1366399831-5964-11-git-send-email-felipe.contreras@gmail.com> In-Reply-To: <1366399831-5964-1-git-send-email-felipe.contreras@gmail.com> Signed-off-by: Felipe Contreras --- contrib/cc-cmd/git-cc-cmd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/cc-cmd/git-cc-cmd b/contrib/cc-cmd/git-cc-cmd index 67a276d..9a2d2fd 100755 --- a/contrib/cc-cmd/git-cc-cmd +++ b/contrib/cc-cmd/git-cc-cmd @@ -237,7 +237,12 @@ commits.items.values.each do |commit| end end -persons.each do |person, roles| +# sort by number of participations +count_sort = lambda do |a, b| + b[1].values.reduce(:+) <=> a[1].values.reduce(:+) +end + +persons.sort(&count_sort).each do |person, roles| roles = roles.map do |role, count| percent = count.to_f * 100 / commits.size next if percent < $min_percent -- 1.8.2.1.790.g4588561