# Order from db

**URL:** <https://www.ruby-forum.com/t/order-from-db/140669>\
**Category:** Rails\
**Created:** [June 17, 2008, 10:51am UTC](https://www.ruby-forum.com/t/order-from-db/140669 "2008-06-17T10:51:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [June 17, 2008, 10:51am UTC](https://www.ruby-forum.com/t/order-from-db/140669/1 "2008-06-17T10:51:16Z")

</div>

When i get data from my db i use :order =\> “articles.title”  
but then i get them like

Adam  
Bono  
Cecar  
anna

How can i get the data like

Adam  
anna  
Bono  
Cecar

not get them case-sensitive.

---

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [June 17, 2008, 2:14pm UTC](https://www.ruby-forum.com/t/order-from-db/140669/2 "2008-06-17T14:14:55Z")

</div>

Hi Mikael,

Mikael BjÃ¶rkegren wrote:

> When i get data from my db i use :order =\> “articles.title”  
>   
> How can i get the data like
> 
> Adam  
> anna  
> Bono  
> Cecar

Have you tried “articles.title.downcase” ? I’m not sure if it will work  
inline in an order statement, but that’s what I’d try first. A second  
solution would be to add a separate column to your table with the field  
stored in that form to use in your finder.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [June 17, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/order-from-db/140669/3 "2008-06-17T14:20:55Z")

</div>

Thanks that worked perfect.

> Well in SQL you’d want to `ORDER BY LOWER(title) ASC’, so give :order  
> =\> “LOWER(articles.title) ASC” a try
> 
> Jason

---

<div class="post-metadata">

**Author:** ![mikael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f04885/32.png) [@mikael](https://www.ruby-forum.com/u/mikael)\
**Post date:** [June 17, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/order-from-db/140669/4 "2008-06-17T14:17:52Z")

</div>

On Tue, Jun 17, 2008 at 8:14 AM, Bill W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > anna  
> > Bill

Well in SQL you’d want to `ORDER BY LOWER(title) ASC’, so give :order  
=\> “LOWER(articles.title) ASC” a try

Jason
