Search code examples
ruby-on-rails-3datemodelcontrollerexif

Rails Pictures sort date


In Exifr for rails (im using this fork https://github.com/picuous/exifr ) how do i sort out the pictures according to date this is how to get the date

EXIFR::JPEG.new('IMG_6841.JPG').date_time           # => Fri Feb 09 16:48:54 +0100 2007

if im too vague let me know how to help


Solution

  • If you have all the pictures as a list just use Ruby's normal sort function (or sort!, if you want it in-place), so:

    images.sort! { |img1, img2| img1.date_time <=> img2.date_time }