# How to sort using active record?

**URL:** <https://www.ruby-forum.com/t/how-to-sort-using-active-record/140854>\
**Category:** Rails\
**Created:** [June 19, 2008, 9:39am UTC](https://www.ruby-forum.com/t/how-to-sort-using-active-record/140854 "2008-06-19T09:39:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaselai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@shaselai](https://www.ruby-forum.com/u/shaselai)\
**Post date:** [June 19, 2008, 9:39am UTC](https://www.ruby-forum.com/t/how-to-sort-using-active-record/140854/1 "2008-06-19T09:39:40Z")

</div>

If I have a database table called Books and I want to sort it by date  
or title, what is the correct command to do so? It probably starts  
with Book.find(…)? thanks!

---

<div class="post-metadata">

**Author:** ![shaselai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@shaselai](https://www.ruby-forum.com/u/shaselai)\
**Post date:** [June 19, 2008, 10:50am UTC](https://www.ruby-forum.com/t/how-to-sort-using-active-record/140854/2 "2008-06-19T10:50:26Z")

</div>

On Jun 19, 7:43 am, shaselai [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If I have a database table called Books and I want to sort it by date  
> or title, what is the correct command to do so? It probably starts  
> with Book.find(…)? thanks!

Book.find(:all, :order =\> “title ASC”)  
Book.find(:all, :order =\> “date DESC”)

just use some SQL order for this param.
