Hiwi! Thank you for reading.
Can someone show me some approaches to sort this Dictionary, no matter ascending or descending, just some approaches to sort it?
Hey! If you’re planning on making a Leaderboard you should take a look at OrderedDataStore | Roblox Creator Documentation. Hopefully this article helps you out. There is an example at the bottom of the page.
Thank you so much!, but thats not the required scenario in this case. Its not possible to save an OrderedDataStore for a small task like this one.
I just want to find a way to sort a dictionary
Well, then you could technically achieve this with table.sort even if you tried this already.
Important to know with table.sort is, it doesn’t return a table. It replaces the old one.
Yup, thats exactly what I did, sort the array gotten from the dictionary, then use that sorted array to match it with the dictionary, creating a new dictionary with all players and points ordered. But, if some players has the same amount of points, I bet, weird things will occur.
Im asking for some other approaches to sort a dictionary
Dictionaries do not have any real order & so attempting to use table.sort by itself probably holds no promise. You will definitely need to do a little extra work like you’ve been trying to.
For sorting of dictionaries I have always used this method that 1waffle1 goes into detail about here:
I see no reason this could not work for your use-case because the sorted variant will still hold the indexes thus making it easy to reattach “OtherStuff” on a per index basis after sorting.
Its just, thats what I’ve been doing, when Players has the same amount of Points, what happens? I think weird stuff occurs, thats all. I just wanna know some new approaches to sort a dictionary