A
A
Alexander Petrov2015-12-25 18:12:22
Ruby on Rails
Alexander Petrov, 2015-12-25 18:12:22

How to sort in ruby?

Probably a stupid question, but I just can't find an answer...
There is an array with articles, each element has public_at properties. You need to sort the array by this property.
HOW TO DO IT?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Kryak, 2015-12-25
@Mirkom63

articles.sort_by(&:public_at)

R
Roman Mirilaczvili, 2015-12-25
@2ord

Active Record Query Interface / Ordering
And, in a good way, do not forget about limiting the output of the number of records.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question