Sticky gravity is explained in depth here: http://tetrisconcept.net/wiki/Line_clear#Sticky
The playfield is divided into connected segments using flood fill. Any blocks that are adjacent horizontally or vertically are marked as one segment, that is, they are treated as having "stuck" together. Each segment falls independently until it meets the floor or another block. Additional line clears may result.
Sample input and expected output are included in this Gist.