From: Nicolas Pouillard Date: Mon, 10 Mar 2008 08:11:17 +0000 (+0100) Subject: sort contacts when saving contacts.txt X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=617bcfe12e8c98a9b924f656215383d4d5ecb743;p=sup sort contacts when saving contacts.txt This makes sup behave more nicely when contacts.txt is under version control. --- diff --git a/lib/sup/contact.rb b/lib/sup/contact.rb index 8050c06..b0c272e 100644 --- a/lib/sup/contact.rb +++ b/lib/sup/contact.rb @@ -51,7 +51,7 @@ class ContactManager def save File.open(@fn, "w") do |f| - @p2a.each do |p, a| + @p2a.sort_by { |(p, a)| [p.full_address, a] }.each do |(p, a)| f.puts "#{a || ''}: #{p.full_address}" end end