Sort::Sort(Iterator* input,
SortColumns sort_columns)
{
this->input = input;
this->sort_columns = sort_columns;
}
|
void Sort::open()
{
// Gather all the input rows.
input->open();
Row* row;
this->rows = new vector<Row*>();
while (row = input->next() {
rows->emplace_back(row);
}
// Actually sort the rows.
std::sort(rows->begin(), rows->end(), RowCompare(sort_columns));
// Prepare for output
this->output = rows->begin();
}
|