Reorganize items from a HTTP request

Hi!

I need to reogarnize the items that come from a HTTP request. Basically the expenses do not come in the correct date order, I need to rearrange it from newest to oldest. Any ideas how?
The item that rules the date is vencimento. All the others items has to come to the correct order also.

JSON example:

[
    {
        "statusCode": 200,
        "headers": [
            {
                "name": "access-control-allow-origin",
                "value": "*"
            },
            {
                "name": "alt-svc",
                "value": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"
            },
            {
                "name": "content-security-policy",
                "value": "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"
            },
            {
                "name": "content-type",
                "value": "application/json; charset=utf-8"
            },
            {
                "name": "cross-origin-embedder-policy",
                "value": "require-corp"
            },
            {
                "name": "cross-origin-opener-policy",
                "value": "same-origin"
            },
            {
                "name": "cross-origin-resource-policy",
                "value": "same-origin"
            },
            {
                "name": "date",
                "value": "Wed, 26 Apr 2023 00:04:48 GMT"
            },
            {
                "name": "etag",
                "value": "W/\"f1e-A+iQGp/VwGPIMuWOvNIMbwapYfM\""
            },
            {
                "name": "origin-agent-cluster",
                "value": "?1"
            },
            {
                "name": "referrer-policy",
                "value": "no-referrer"
            },
            {
                "name": "server",
                "value": "nginx/1.21.6"
            },
            {
                "name": "strict-transport-security",
                "value": "max-age=15552000; includeSubDomains"
            },
            {
                "name": "vary",
                "value": "Accept-Encoding"
            },
            {
                "name": "x-content-type-options",
                "value": "nosniff"
            },
            {
                "name": "x-dns-prefetch-control",
                "value": "off"
            },
            {
                "name": "x-download-options",
                "value": "noopen"
            },
            {
                "name": "x-frame-options",
                "value": "SAMEORIGIN"
            },
            {
                "name": "x-permitted-cross-domain-policies",
                "value": "none"
            },
            {
                "name": "x-xss-protection",
                "value": "0"
            },
            {
                "name": "connection",
                "value": "close"
            },
            {
                "name": "transfer-encoding",
                "value": "chunked"
            }
        ],
        "cookieHeaders": [],
        "data": {
            "inscricao": "76225",
            "id_proprietario": 261726,
            "proprietario": "76225 - - IVONE TEREZINHA DA SILVA",
            "id_compromissario": null,
            "compromissario": null,
            "id_grupo": 9162,
            "grupo": "Imobili√°ria",
            "identificador": "99999",
            "observacoes": null,
            "centro_de_custo": null,
            "cod_ibge": 420420,
            "cidade": "Chapecó",
            "estado": "SC",
            "cep": "89801222",
            "lote": "0000",
            "bairro": "MARIA GORETTI",
            "quadra": "000000",
            "logradouro": "ASSIS BRASIL 153 E",
            "numero": null,
            "metragem": 0,
            "valor_venal": 5224.14,
            "valor_atraso_ano_corrente": 0,
            "valor_atraso_anos_anteriores": 0,
            "valor_em_dia": 0,
            "situacao": "EM_ANDAMENTO",
            "ultima_atualizacao": "2023-04-26T00:03:47.000Z",
            "debitos": [
                {
                    "id_debito": 3678061,
                    "ano": "2023",
                    "parcela": "001",
                    "descricao": "IPTU",
                    "vencimento": "2023-04-26",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 148.23,
                    "linha_digitavel": null,
                    "caminho_boleto": null,
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678062,
                    "ano": "2023",
                    "parcela": "010",
                    "descricao": "IPTU",
                    "vencimento": "2023-12-11",
                    "valor_inicial": 139.82,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.82,
                    "linha_digitavel": "10498332608100010004004824324000295610000013982",
                    "caminho_boleto": "2023/12/SC/chapeco/76225-c5a55d51b62b47c3903d475440c580f0.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678063,
                    "ano": "2023",
                    "parcela": "009",
                    "descricao": "IPTU",
                    "vencimento": "2023-11-10",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323960695300000013984",
                    "caminho_boleto": "2023/11/SC/chapeco/76225-0d8c4dcbd18b469b9fa20ae20f4f9c72.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678064,
                    "ano": "2023",
                    "parcela": "008",
                    "descricao": "IPTU",
                    "vencimento": "2023-10-10",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323887894990000013984",
                    "caminho_boleto": "2023/10/SC/chapeco/76225-a6a349c55af54f2690772ad193796980.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678065,
                    "ano": "2023",
                    "parcela": "007",
                    "descricao": "IPTU",
                    "vencimento": "2023-09-11",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323705794700000013984",
                    "caminho_boleto": "2023/9/SC/chapeco/76225-6c78304b3919460595a06d9f147d1081.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678066,
                    "ano": "2023",
                    "parcela": "006",
                    "descricao": "IPTU",
                    "vencimento": "2023-08-10",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323614394380000013984",
                    "caminho_boleto": "2023/8/SC/chapeco/76225-3aadda72af5d4733a21f90ee56ba4047.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678067,
                    "ano": "2023",
                    "parcela": "005",
                    "descricao": "IPTU",
                    "vencimento": "2023-07-10",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323531394070000013984",
                    "caminho_boleto": "2023/7/SC/chapeco/76225-483ab128b1724affb99cc4e12ae9ac75.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678068,
                    "ano": "2023",
                    "parcela": "004",
                    "descricao": "IPTU",
                    "vencimento": "2023-06-12",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323457193790000013984",
                    "caminho_boleto": "2023/6/SC/chapeco/76225-aafe3e705573429bae8c56bd26721886.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                },
                {
                    "id_debito": 3678069,
                    "ano": "2023",
                    "parcela": "003",
                    "descricao": "IPTU",
                    "vencimento": "2023-05-10",
                    "valor_inicial": 139.84,
                    "acrescimos": 0,
                    "descontos": 0,
                    "valor_final": 139.84,
                    "linha_digitavel": "10498332608100010004004824323374193460000013984",
                    "caminho_boleto": "2023/5/SC/chapeco/76225-da5b32cffb7d4e62bfc0bb033a939b23.pdf",
                    "possui_boleto": null,
                    "fl_boleto": 0,
                    "fl_unica": 0
                }
            ],
            "mensagem": {
                "iptu": "Erro desconhecido",
                "divida_ativa": null
            }
        },
        "fileSize": 3870
    }
]

Since you have a date in the format of YYYY-MM-DD, I think you can directly use the sort function for this.

{{sort(1.debitos; ‚Äúvencimento‚ÄĚ)}}

This will result in an array of debitos in ascending order by date.

2 Likes