Function to draw rows from a table according to weights.