views:

44

answers:

0

Hello,

I have a collection of Blog items.

@blogs = Blog.find(:all)

Each blog has a description textfield with some text. What I would like to do is splitting the @blogs objects into 3 divs, but with roughly the same characters in each column.

<div id="left">
  #blog1 (653 characters)
</div>

<div id="center">
  #blog2 (200 characters)
  #blog5 (451 characters)
</div>

<div id="right">
  #blog3 (157 characters)
  #blog4 (358 characters)
  #blog6 (155 characters)
</div>

I can't figure out how to do that without getting really complicated and probably inefficient.

So far I have thought about converting the description field (size) to % of total characters in the @blogs collection, but how do I match/split the elements, so that I get closest to 33% in each column - like a super simple tetris game :)

Any thoughts?