# Column sort (Noobie question)

**URL:** <https://www.ruby-forum.com/t/column-sort-noobie-question/67488>\
**Category:** Ruby\
**Created:** [September 4, 2006, 3:40pm UTC](https://www.ruby-forum.com/t/column-sort-noobie-question/67488 "2006-09-04T15:40:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptejada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/85f322/32.png) [@ptejada](https://www.ruby-forum.com/u/ptejada)\
**Post date:** [September 4, 2006, 3:40pm UTC](https://www.ruby-forum.com/t/column-sort-noobie-question/67488/1 "2006-09-04T15:40:10Z")

</div>

I am write a program to sort pictures, I can read in the directory and  
rename the picture basied on the exif information but I now want to do  
load the directory and exif timestamp into a two column table and then  
sort. I have searched for a multi column array or table but have not  
found an example. Any suggestions?

Thanks,

-Pablo

---

<div class="post-metadata">

**Author:** ![ptejada](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/85f322/32.png) [@ptejada](https://www.ruby-forum.com/u/ptejada)\
**Post date:** [September 4, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/column-sort-noobie-question/67488/2 "2006-09-04T16:11:27Z")

</div>

On 9/4/06, Pablo T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am write a program to sort pictures, I can read in the directory and  
> rename the picture basied on the exif information but I now want to do  
> load the directory and exif timestamp into a two column table and then  
> sort. I have searched for a multi column array or table but have not  
> found an example. Any suggestions?

You could probably use an array of arrays, and the sort\_by method.  
This sorts a two-column table by name:

table = [[‘name03’,], [‘name02’,],  
[‘name01’,]]

table.sort\_by { |element| element[0] }

The above example is not “real” Ruby code because of the “”  
thingies, but it should work if you use it with your real data.
