Skip to content

Commit

Permalink
Merge pull request #50 from digininja/sort-months
Browse files Browse the repository at this point in the history
Sort months correctly
  • Loading branch information
digininja committed Aug 4, 2021
2 parents d1129e4 + a15d0af commit a1e659e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions checkers_available/date_checker.rb
Expand Up @@ -66,6 +66,28 @@ def get_results()
ret_str = "None found\n"
end

count_ordered = []
@months.each_pair do |month, count|
count_ordered << [month, count] unless count == 0
end
months_sorted = count_ordered.sort do |x,y|
(x[1] <=> y[1]) * -1
end

ret_str << "\nMonths (Frequency ordered)\n"
disp = false
months_sorted.each do |data|
month = data[0]
count = data[1]
unless count == 0
disp = true
ret_str << "#{month} = #{count.to_s} (#{((count.to_f/@total_words_processed) * 100).round(2).to_s}%)\n" unless count == 0
end
end
unless disp
ret_str = "None found\n"
end

ret_str << "\nDays\n"
disp = false
@days.each_pair do |day, count|
Expand Down
2 changes: 1 addition & 1 deletion pipal.rb
Expand Up @@ -25,7 +25,7 @@
require'json'
require "pathname"

VERSION = "3.1"
VERSION = "3.1.1"

# Find out what our base path is
base_path = File.expand_path(File.dirname(__FILE__))
Expand Down

0 comments on commit a1e659e

Please sign in to comment.