How to sort a dictionary in Robot Framework using a custom function

I’m trying to validate the API result with data extracted from an Oracle database. For this, I make a query in the database and store the result in a dictionary-type variable.

${query}    Query    SELECT * FROM VEH_MAKE_LKP WHERE vkl_is_active=1 ORDER BY VKL_CODE ASC
Log Many    @{query}

This gives me a return like this:

My validation needs to be by the first text column in the image and that’s where my problems start because Robot’s sorting method is different from the one used by Oracle.

To sort this dictionary I’m using the function below:

@{sorted_query}    Evaluate    sorted(@{query}, key=lambda v: v[1])

But as I said when there are uppercase and lowercase letters, numbers, and special characters, the sorting is different and at a certain point, the validation fails.

I believe I needed to make the Robot sort obey the following criteria:

${SPACE}_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

But I don’t know how to do that. Can someone explain to me how instead of using a lambda function, use a customizable function that followed the sequence above?

Thanks in advance