static int guessOutputWidth( List<ArrangedSprite> sprites )
{
// Gather the widths of all our sprites into a temporary list.
var widths = new List<int>();
foreach( ArrangedSprite sprite in sprites )
{
widths.Add( sprite.width );
}
// Sort the widths into ascending order.
widths.Sort();
// Extract the maximum and median widths.
var maxWidth = widths[widths.Count - 1];
var medianWidth = widths[widths.Count / 2];
// Heuristic assumes an NxN grid of median sized sprites.
var width = medianWidth * (int)Math.Round( Math.Sqrt( sprites.Count ) );
// Make sure we never choose anything smaller than our largest sprite.
return Math.Max( width, maxWidth );
}