Forum: Ruby sort on European date

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee6788c2faaad7a5cd0bc466c9ea60d8?d=identicon&s=25 aidy (Guest)
on 2009-06-08 17:46
(Received via mailing list)
Hi,

date = ['15/10/1971', '16/10/1972', '12/12/1971']
real = date.map {|s| Date.parse s}
puts real.sort

Could anyone please tell me how I can parse the date in this sort with
a European format?

Thanks

Aidy
8f6f95c4bd64d5f10dfddfdcd03c19d6?d=identicon&s=25 Rick Denatale (rdenatale)
on 2009-06-08 18:08
(Received via mailing list)
On Mon, Jun 8, 2009 at 11:45 AM, aidy<aidy.lewis@googlemail.com> wrote:
> Hi,
>
> date = ['15/10/1971', '16/10/1972', '12/12/1971']
> real = date.map {|s| Date.parse s}
> puts real.sort
>
> Could anyone please tell me how I can parse the date in this sort with
> a European format?

  real = date.map {|s| Date.strptime(s, "%d/%m/%Y")}


--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
This topic is locked and can not be replied to.