From mboxrd@z Thu Jan 1 00:00:00 1970 From: grant@antiflux.org (Grant Hollingworth) Date: Fri, 25 Jan 2008 10:04:22 -0500 Subject: [sup-talk] [PATCH] return sources in id-order, with non-archived sources first In-Reply-To: <1201238649-sup-7598@south> References: <1200675726-sup-4860@spooky.local> <1201238649-sup-7598@south> Message-ID: <1201272768-sup-3795@spooky.local> * William Morgan [Fri Jan 25 00:27:14 -0500 2008]: > > + 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 } I probably did that because it's likely that an inbox is the first source. It's not really necessary. I think partition is clearer than sort_by in this case. How about changing @sources to an array?