sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 6bfbddb5c5b970ffd7c939b858d8f6c46cc27a04
parent b2eb50b23e365377086857e467ac0f2199d6ca05
Author: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com>
Date:   Sun, 24 Nov 2013 11:06:58 -0800

Merge pull request #184 from rakoo/discussion-order

Sort containers by message date and id
Diffstat:
M lib/sup/thread.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -172,7 +172,7 @@ class Container
 
   def each_with_stuff parent=nil
     yield self, 0, parent
-    @children.each do |c|
+    @children.sort_by(&:sort_key).each do |c|
       c.each_with_stuff(self) { |cc, d, par| yield cc, d + 1, par }
     end
   end
@@ -239,6 +239,10 @@ class Container
     indent += 3
     @children.each { |c| c.dump_recursive f, indent, false, self }
   end
+
+  def sort_key
+    empty? ? [Time.now.to_i, ""] : [@message.date.to_i, @message.id]
+  end
 end
 
 ## A set of threads, so a forest. Is integrated with the index and