commit 2723a736691ea122d476d54f82e7c63611fd21b3
parent b2eb50b23e365377086857e467ac0f2199d6ca05
Author: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com>
Date: Sun, 24 Nov 2013 17:34:45 +0100
Sort containers by message date and id
Diffstat:
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