public function build($columns = [])
    {
        $headers = [];
        $data = [];
        $dataFormats = [];
        $aggregations = [];
        $aggregationsFormats = [];
        $metaData = [];

        foreach ($this->indexes as $index) {
            $columnsNames = array_keys($this->columns);

            $line = [];
            foreach ($columnsNames as $columnName) {
                $columnValues = $this->columns[$columnName]->getValues();

                $line = array_merge($line, [$columnName => $columnValues[$index]]);
            }

            $data[$index] = $this->orderColumns($line, $columns);
        }

        foreach ($this->columns as $columnName => $column) {
            $dataFormats[$columnName] = $column->getFormat();

            $headers = array_merge($headers, [$columnName => $column->getHeaderName()]);
            $metaData = array_merge($metaData, [$columnName => $column->getMetaData()]);

            $columnAggregation = $column->getAggregation();
            if ($columnAggregation) {
                $aggregationValue = $columnAggregation->aggregate($this);
                $aggregationsFormats[$columnName] = $columnAggregation->getFormat();
            } else {
                $aggregationValue = null;
            }
            $aggregations = array_merge($aggregations, [$columnName => $aggregationValue]);
        }

        $headers = $this->orderColumns($headers, $columns);
        $metaData = $this->orderColumns($metaData, $columns);
        $aggregations = $this->orderColumns($aggregations, $columns);

        return new StatsTable($data, $headers, $aggregations, $dataFormats, $aggregationsFormats, $metaData);
    }