s = [ { "requisites": { "partyId": "722725f9-0b34-4835-93cf-fa3d588dbc13", "organizationId": "45ba6290-d4da-431e-bfd5-47e2d1be6806", "organizationGln": "2235515362949", "organizationType": "ShipperOrConsignee", "organizationRegistrationDate": "" } }, { "requisites": { "partyId": "722725f9-0b34-4835-93cf-fa3d588dbc13", "organizationId": "3fba6290-d4da-431e-bfd5-47e2d1be6806", "organizationGln": "2128483838953", "organizationType": "PayerOrBuyer", "organizationRegistrationDate": "2025-11-29T00:00:00Z" } }, { "requisites": { "partyId": "722725f9-0b34-4835-93cf-fa3d588dbc13", "organizationId": "3fba6290-d4da-431e-bfd5-47e2d1be6806", "organizationGln": "2128483838953", "organizationType": "PayerOrBuyer", "organizationRegistrationDate": "2025-11-29T00:00:00Z" } }, { "requisites": { "partyId": "722725f9-0b34-4835-93cf-fa3d588dbc13", "organizationId": "45ba6290-d4da-431e-bfd5-47e2d1be6806", "organizationGln": "2235515362949", "organizationType": "ShipperOrConsignee", "organizationRegistrationDate": "" } } ]
The list may contain more than a thousand dictionaries.
How can I sort the following list so that dictionaries with the value PayerOrBuyer always appear first in the list?
I understand that sorting needs to be done through a lambda function, but I don’t understand how to apply it.
misantro0p is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1