From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Thu, 24 Jan 2008 21:27:14 -0800 Subject: [sup-talk] [PATCH] return sources in id-order, with non-archived sources first In-Reply-To: <1200675726-sup-4860@spooky.local> References: <1200675726-sup-4860@spooky.local> Message-ID: <1201238649-sup-7598@south> Reformatted excerpts from Grant Hollingworth's message of 2008-01-18: > To speed up the user's view of polling, deal with sources that affect > the inbox before (for example) large mailing lists. It seemed tidier > to implement this in Index rather than PollManager. Very nice. One minor comment below. > I changed "@sources.values" to "sources" in some other methods for > clarity, which I think in this case outweighs lost efficiency. Sounds good. And efficiency is the least of our concerns! > + def sources > + ## favour the inbox by listing non-archived sources first > + @sources.values.sort_by {|s| s.id }.partition {|s| !s.archived? }.flatten > + end Why bother sorting by id at all? Why not just something like: @sources.values.sort_by { |s| s.archived? ? 0 : 1 } -- William