function compact(layout
/*: Layout*/
, verticalCompact
/*: Boolean*/
, forceAbsolute
/*: boolean*/
)
/*: Layout*/
{
  if (forceAbsolute) return layout; // Statics go in the compareWith array right away so items flow around them.

  var compareWith = getStatics(layout); // We go through the items by row and column.

  var sorted = sortLayoutItemsByRowCol(layout); // Holding for new items.

  var out = Array(layout.length);

  for (var i = 0, len = sorted.length; i < len; i++) {
    var l = sorted[i]; // Don't move static elements

    if (!l.static) {
      l = compactItem(compareWith, l, verticalCompact); // Add to comparison array. We only collide with items before this one.
      // Statics are already in this array.

      compareWith.push(l);
    } // Add to output array to make sure they still come out in the right order.


    out[layout.indexOf(l)] = l; // Clear moved flag, if it exists.

    l.moved = false;
  }

  return out;
}
Given a layout, compact it. This involves going down each y coordinate and removing gaps
between items.

@param  {Array} layout Layout.
@param  {Boolean} verticalCompact Whether or not to compact the layout
  vertically.
@return {Array}       Compacted Layout.