Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

MyBuilder Tech Blog:
Using Constraint-based Ordering in PHP
Nov 28, 2016 @ 17:09:18

On the MyBuilder.com Tech blog they've posted a tutorial from Edd Mann looking at the use of constraint-based ordering in PHP applications.

An interesting problem arose last week when we wished to generate a listing of recently completed jobs (along with their shortlist fees). Upon review of some earlier attempts, we did not like the aesthetics present when many of a particular shortlist fee were clustered together (i.e. two or more adjacent jobs with the same shortlist fee). What we were instead looking for was to create a constraint-based ordering that when applied to the recently completed jobs, would give an even distribution of shortlist fees (data-set permitting).

Initially he tried a "low-high" ordering method based on their "fee" value. Instead, to make the solution more "random" he reframed the need and broke it down into three separate actions: sort, partition and interleave. As PHP only has one of those, he came up with his own solutions for the other two (code included). He explains briefly how it all works together and what kind of benefits it has over the low-high solution originally created.

tagged: tutorial constraint based ordering example partition interleave

Link: http://tech.mybuilder.com/using-constraint-based-ordering-in-php/


Trending Topics: