Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:02:00+00:00 2026-06-07T15:02:00+00:00

I am programming a section of a website which contains a stream of posts.

  • 0

I am programming a section of a website which contains a stream of posts. The posts are of various size, but contain only text. What I wish to do is take the text of the posts from the server, then:

  1. Organize them into Large, Medium, and Small size posts by the number of characters they contain.enter image description here

  2. Combine the posts into a stack such that when it is displayed, all of the posts are flush with the edges. This requires that every row of posts is of the same width.enter image description here

The posts are in a div that is set to automatically put the posts on the next line when they overflow, so the only issue is placing the posts in the div in the right order.

For example, the code for figure/image 2 is:

<div class="small_posts" ></div><div class="medium_posts"></div>
<div class="medium_posts"></div><div class="small_posts" ></div>
<div class="small_posts" ></div><div class="tiny_posts"  ></div><div class="tiny_posts"></div>

The text for the posts comes in a linear array from a MySQL database, and I am receiving and displaying it with PHP.

My issue is not how to implement this in PHP, but rather how to design an algorithm to do this in the first place.

My attempted designed so far have been shoddy hacks, of too little quality to mention.

I would greatly appreciate some advice on how to design an algorithm to efficiently sort these posts into flush rows.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:02:03+00:00Added an answer on June 7, 2026 at 3:02 pm

    You can find also the solution with javascript
    Check it out this plugin http://masonry.desandro.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working through SICP's section on Logic Programming, but I got stuck
I am building a website just for fun of learning programming more fully, but
I recently did a programming test in which there was a ifstream section which
In Karl Seguin's Foundations of Programming there is a small section on using the
In Apple's The Objective-C Programming Language: Defining a Class the section named Redefining self
I was going through the Martin Odersky's book Programming in Scala with it's section
Recently, while reading a Socket Programming HOWTO the following section jumped out at me:
In section 7.1.1 of the book The C++ Programming Language the author states: inline
Please forgive my ignorance and poor SQL programming skills but I am normally a
I am reading some C text at the address https://cs.senecac.on.ca/~btp100/pages/content/const.html . In the section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.