**Describe what's wrong**

Selecting from a Buffer table with ORDER BY <col> DESC clause returns wrong rows, and the returned rows are not ordered.

**Does it reproduce on recent release?**

Tested version: 22.7.2.15

**How to reproduce**

* Which ClickHouse server version to use
22.7.2.15
* `CREATE TABLE` statements for all tables involved

        CREATE TABLE mydb.mytable_stored
        (
            `a` UInt8
        )
        ENGINE = MergeTree
        ORDER BY a;

        CREATE TABLE mydb.mytable
        (
            `a` UInt8
        )
        ENGINE = Buffer('mydb', 'mytable_stored', 4, 600, 3600, 10, 100, 10000, 10000000);

* Sample data for all these tables
Note: rows must be inserted one-by-one:

        INSERT INTO mydb.mytable VALUES (0);
        INSERT INTO mydb.mytable VALUES (1);
        INSERT INTO mydb.mytable VALUES (2);
        INSERT INTO mydb.mytable VALUES (3);
        INSERT INTO mydb.mytable VALUES (4);
        INSERT INTO mydb.mytable VALUES (5);
        INSERT INTO mydb.mytable VALUES (6);
        INSERT INTO mydb.mytable VALUES (7);
        INSERT INTO mydb.mytable VALUES (8);
        INSERT INTO mydb.mytable VALUES (9);

* Queries to run that lead to unexpected result

        SELECT a FROM mydb.mytable ORDER BY a DESC LIMIT 5;
        ┌─a─┐
        │ 3 │
        │ 7 │
        └───┘
        ┌─a─┐
        │ 2 │
        │ 6 │
        └───┘
        ┌─a─┐
        │ 1 │
        └───┘
        5 rows in set. Elapsed: 0.007 sec.

(Interestingly, ascending order *seems* to work, did not test it thoroughly though.)

**Expected behavior**

Get the results in descending order, ie. `9, 8, 7, 6, 5`.

**Additional context**

Selecting the maximal value works:

        SELECT max(a) FROM mydb.mytable;
        ┌─max(a)─┐
        │      9 │
        └────────┘
        1 row in set. Elapsed: 0.007 sec.

After the rows are flushed to the backing MergeTree table, the results are good.

        OPTIMIZE TABLE mydb.mytable;
        SELECT a FROM mydb.mytable ORDER BY a DESC LIMIT 5;
        ┌─a─┐
        │ 9 │
        │ 8 │
        │ 7 │
        │ 6 │
        │ 5 │
        └───┘
        5 rows in set. Elapsed: 0.008 sec. 


{
                LOG_WARNING(log, "Destination table {} have different type of column {} ({} != {}). Block of data is converted.", destination_id.getNameForLogs(), backQuoteIfNeed(column.name), dst_col.type->getName(), column.type->getName());
                column.column = castColumn(column, dst_col.type);
                column.type = dst_col.type;
            }
            block_to_write.insert(column);
        }
    }
    if (block_to_write.columns() == 0)
    {
        LOG_ERROR(log, "Destination table {} have no common columns with block in buffer. Block of data is discarded.", destination_id.getNameForLogs());
        return;
    }
    if (block_to_write.columns() != block.columns())
        LOG_WARNING(log, "Not all columns from block in buffer exist in destination table {}. Some columns are discarded.", destination_id.getNameForLogs());
    auto list_of_columns = std::make_shared<ASTExpressionList>();
    insert->columns = list_of_columns;
    list_of_columns->children.reserve(block_to_write.columns());
    for (const auto & column : block_to_write)
        list_of_columns->children.push_back(std::make_shared<ASTIdentifier>(column.name));
    auto insert_context = Context::createCopy(getContext());
    insert_context->makeQueryContext();
    InterpreterInsertQuery interpreter{insert, insert_context, allow_materialized};
    auto block_io = interpreter.execute();
    PushingPipelineExecutor executor(block_io.pipeline);
    executor.start();
    executor.push(std::move(block_to_write));
    executor.finish();
}
void StorageBuffer::backgroundFlush()