Sorting a data table

How do I… create a data table?

I need to create a league table for my game, showing Team Name, Game Played and Number of Points.
The graphical aspects are not a problem (width, row and column high are all fixed). I know sorting could be done at the variable level, with 2 nested loops, but I need some indication to how to proceed.

I found this project very useful to sort the position, but I would prefer not having a single textbox with all the data inside:


1 Like

You can easily adapt the example I made to your own needs.

If I remember, yes, the project uses a nested loop to order the values, and then it concatenates them in a single string for simple display purposes in a textbox. You can just override the concatenation part by replacing it for something that suits your game. After the loops the sorted values must be stored in some kind of array, you can use that to populate your own display.

Anyways, I’m almost sure since that old example many cool extensions have been published, so you must check that first.

Hi @erdo,

thanks for your reply, I managed to display in one column the team names and in another one the team points in separate textboxes, but I have no idea how to sort the textboxes with the accumulated points (and consequently those with the team names). I think the ‘sort numbers in array’ function in the Array Tool extension could be helpful, but I don’t understand how to apply it…

I would first sort the data in the arrays in the same way I did it in my example, and then populate the textboxes, instead of sort the textboxes with the already loaded data.

I didn’t use the array functions to do it at that time, that’s why I recommend to check if there isn’t a easier way to do it through the new functions, or even a full extension.

IF I have some time during the weekend, I’ll try to put together a solution for you based on my example, but I insist: I think there are better ways to do this by now.

I’m quite new to Gdevelop and programming logic in general, so thank you very much for your insight about starting from the arrays and then populate the textboxes.
I’m mostly reverse-engenieering other examples to fit mine game but in this case I’m stuck, so thank you in advance!

1 Like