• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Referencing entries on a ds_grid after sorting it

T

Toxicosis

Guest
I was wondering, is there a way in which a ds_grid's entries can be referenced again after they are sorted?

Let's say I have a specific row in a ds_grid. If I sort the grid, the old row might (or might not) be displaced to a different row number. Is there any way to get the row's new number after sorting? The only way I can think of is adding a column for "initial row", then checking one by one the values until I find the old one. That cannot be too efficient.

Thanks for your time.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Adding your said "index column" and using ds_grid_value_y to find the row index again would be the best approach, since ds_grid does not store row indexes as-is.
Other option would be to store an array with actual data in one column and "weight" in other column (meaning that references to arrays would remain valid after sorting), but whether this is a good idea would depend on other factors as well.
 
Top