I have a list of documents and I want to display them grouped by the first letter of their name on a web-page, over three columns.
In short, something like this:
A | C | E
A | D | F
B | D | F
B | D | F
| D |
An important difference from say, the Windows Explorer view style is that I want letters to stay with each other. No breaking mid-group. To accommodate this, I don't care if one column is a couple of entries too tall.
I've started by sorting the array of documents by name and splitting them into a nested array. So I know (or can easily find out):
- How many unique letters there are
- How many letters there are in each group
- How many entries there are in total
- The mean average of how many values there should be in each column (ideally but not neccessarily)
I don't care what your answers come in. I'm looking for the algorithm rather than the implementation so you can code in anything you like (except perhaps Fortran). an explanation in HTML might be a toughie too.
I invite somebody to go wild on the tags because I couldn't think of anything relevant and no, this isn't homework, so please don't mark it as such.