Sorting logs received by Elasticsearch

My goal is to sort millions of logs by timestamp that I receive out of elastic.

Example logs:

{"realIp": "", "@timestamp": "2020-12-06T02:00:09.000Z"}
{"realIp": "", "@timestamp": "2020-12-06T02:01:09.000Z"}
{"realIp": "", "@timestamp": "2020-12-06T02:02:09.000Z"}
{"realIp": "", "@timestamp": "2020-12-06T02:04:09.000Z"}

Unfortunately, I am not able to get all the logs sorted out of Elastic. It seems like I have to do it by myself.

Approaches i have tried to get the data sorted out of elastic:

es = Search(index="somelogs-*").using(client).params(preserve_order=True)
for hit in es.scan():

another approach:

notifications = (es
    .query("range", **{
        "@timestamp": {
            'gte': 'now-48h',
            'lt' : 'now'

So I am looking for a way to sort these logs by myself or directly through Elasticsearch. Currently, I am saving all the data in a local ‘logs.json’ and it seems to me I have to iter over and sort it by myself.

Source: Python-3x Questions