# Order by date

**URL:** <https://www.ruby-forum.com/t/order-by-date/120221>\
**Category:** Rails\
**Created:** [November 14, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/order-by-date/120221 "2007-11-14T21:23:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e9bcb4/32.png) [@Lewis](https://www.ruby-forum.com/u/Lewis)\
**Post date:** [November 14, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/order-by-date/120221/1 "2007-11-14T21:23:37Z")

</div>

Hi,

I am trying to create a site which displays news from different  
sources. I have the news articles in a MySQL database. On the  
list.rhtml page I display the news articles but they are stored in the  
db in no particular order. How do I get ruby to order these by date,  
newest first, when they are displayed?

Thanks, Lewis

---

<div class="post-metadata">

**Author:** ![Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e9bcb4/32.png) [@Lewis](https://www.ruby-forum.com/u/Lewis)\
**Post date:** [November 14, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/order-by-date/120221/2 "2007-11-14T21:30:07Z")

</div>

NewsArticle.find(:all, :order =\> “created\_on DESC”)

assuming, you model is named NewsArticle and has the timestamps

---

<div class="post-metadata">

**Author:** ![Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e9bcb4/32.png) [@Lewis](https://www.ruby-forum.com/u/Lewis)\
**Post date:** [November 14, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/order-by-date/120221/3 "2007-11-14T22:05:48Z")

</div>

Thanks, my model is named feeditems and the timestamp column is called  
publishdate.

How do I update the code to reflect this?

On 14 Nov, 20:30, Thorsten M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e9bcb4/32.png) [@Lewis](https://www.ruby-forum.com/u/Lewis)\
**Post date:** [November 15, 2007, 6:13pm UTC](https://www.ruby-forum.com/t/order-by-date/120221/4 "2007-11-15T18:13:17Z")

</div>

Lewis wrote:

> Thanks, my model is named feeditems and the timestamp column is called  
> publishdate.
> 
> How do I update the code to reflect this?
> 
> On 14 Nov, 20:30, Thorsten M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

FeedItems.find(:all, :order =\> “publishdate DESC”)
