From: "David A. Black" Date: 2009-08-31T06:07:58+09:00 Subject: Re: Sorting an array by multiple elements? --1926193751-284449353-1251666463=:16664 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-284449353-1251666463=:16664" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-284449353-1251666463=:16664 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Mon, 31 Aug 2009, Robert Dober wrote: > On Sun, Aug 30, 2009 at 1:25 PM, David A. Black wrote: >> On Sun, 30 Aug 2009, David A. Black wrote: >> >>> �data.sort_by {|id, date, num, name| [id, date, num] } >> >> Whoops, I meant [name, date, id]. >> > Maybe you might have avoided this by using > | id, date, _, name | > I say this because the importance of naming is maybe one of the most > underrated in programming. Nothing that profound going on; I just got it wrong :-) In fact, I wrote what I meant to write; I'd just read the requirements slightly wrong, so I listed the wrong set of variables. So if I'd used _ (which I never do; it always looks kind of odd to me), I would have written |id, date, num, _|, since for whatever reason I had zeroed in on those variables. David -- David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com Ruby/Rails training, mentoring, consulting, code-review Latest book: The Well-Grounded Rubyist (http://www.manning.com/black2) September Ruby training in NJ has been POSTPONED. Details to follow. --1926193751-284449353-1251666463=:16664-- --1926193751-284449353-1251666463=:16664--