0 votes

Hi, I need to sort an Array of Dictionaries, in order by multiple parameters:

Array = [
{"Score": int1, "Years": int1, "Month": int1, "Situation": "String2"},
{"Score": int2, "Years": int2, "Month": int2, "Situation": "String1"},
{"Score": int3, "Years": int3, "Month": int3, "Situation": "String1"},
{"Score": intN, "Years": intN, "Month": intN, "Situation": "String3"}

This is my Array... I need to order by "Score", at the same "Score" by "Years", at the same "Score" and "Years" by "Month", at the same "Score", "Years" and "Month" by "Situation" ("" previous the != "")...

Someone can help me?

in Engine by (12 points)

1 Answer

0 votes

yoi can use your own custome sort function.

Read about it here:

For that you have to provide a function that compares two items and return true or false depending on if item A should be "on top" of item B.

by (3,922 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.