On Jul 15, 2010, at 3:51 PM, Marnen Laibow-Koser wrote:
Phillip Koebbe wrote:
Marnen Laibow-Koser wrote:
[...]
## Column-wise is a bit more work

irb> row_count = (array.length + (3-1))/3
=> 5
irb> columns = []
=> []
[...]

Why go to all that trouble? in_groups and zip. Done. No arithmetic.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

That really depends on what the desired output is.

You're right. I assumed the OP wanted the output he said he wanted. :)

The OP indicated that
he was looking for a phone book style sorting, top-to-bottom,
left-to-right.

I know that.


It currently sorts my categories as below:

| Category1 Category2 Category3 | Category4 Category5 Category6 |

This is not what I want. What I want is:

| Category1 | Category4 |
| Category2 | Category5 |
| Category3 | Category6 |

in_groups doesn't do exactly that.

I'm aware of that.  That's why I suggested in_groups *and zip*, which
will do exactly what the OP wanted.

Please don't only read half of my solution and claim I'm wrong because
you missed the rest.

It would be so much less confusing if you would answer in actual *code* rather than just spewing documentation.

-Rob


Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails- [email protected]. To unsubscribe from this group, send email to [email protected] . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en .


Rob Biedenharn          
[email protected]     http://AgileConsultingLLC.com/
[email protected]               http://GaslightSoftware.com/

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to