Leave a specific row on top of sorted results

7 views
Skip to first unread message

fugee ohu

unread,
Jun 4, 2018, 7:10:35 AM6/4/18
to Ruby on Rails: Talk
How do I leave a specific row on top of sorted results I'm displaying news stories and I want the top story to stay on top for as long as it's the top story

Colin Law

unread,
Jun 4, 2018, 8:31:35 AM6/4/18
to Ruby on Rails: Talk
On 4 June 2018 at 12:10, fugee ohu <fuge...@gmail.com> wrote:
How do I leave a specific row on top of sorted results I'm displaying news stories and I want the top story to stay on top for as long as it's the top story

I can't understand how you have to keep asking such basic questions.  Isn't it obvious?  Mark it in some way then do a sort on the two fields (top or not, and date or whatever else you are sorting by) so that it sorts by date within the topiness value.  Alternatively just remove it from the set to be sorted before you sort them.

Colin
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/145c5f68-c155-4b8f-a4f6-8fbc7161f469%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

fugee ohu

unread,
Jun 4, 2018, 8:56:16 AM6/4/18
to Ruby on Rails: Talk


On Monday, June 4, 2018 at 8:31:35 AM UTC-4, Colin Law wrote:
On 4 June 2018 at 12:10, fugee ohu <fuge...@gmail.com> wrote:
How do I leave a specific row on top of sorted results I'm displaying news stories and I want the top story to stay on top for as long as it's the top story

I can't understand how you have to keep asking such basic questions.  Isn't it obvious?  Mark it in some way then do a sort on the two fields (top or not, and date or whatever else you are sorting by) so that it sorts by date within the topiness value.  Alternatively just remove it from the set to be sorted before you sort them.

Colin
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.


Sorry you're right Of course I know how to do it I wanted to know if there was a commonly used helper method that I didn't know about I decided it wasn't a good idea anyway and made a special section for top story because otherwise people will assume it's still the most recent story and disregard the following stories every time they revisit the page
Reply all
Reply to author
Forward
0 new messages