Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I order a list of values on a Surface UI from greatest to least?

Here's what I tried before my ROBLOX Studio crashed, took a screenshot so sorry for the white overlay.

Screenshot: http://prntscr.com/kgt31n

I've never used table.sort, table.concat, or tried to order a table from greatest to least. Let alone an entire UI. The names of the frames inside the "List" are numbers converted to int values as seen in the script. I've reread over the wiki's description over these and still couldn't grasp it. Could someone help me out? Really struggling with this q.q

1 answer

There's a ROBLOX Gui element that is absolutely perfect for this, the UIListLayout. Insert a UIListLayout in the frame, and set the sort order to LayoutOrder. Then, on every object, set the LayoutOrder property to the position you wish it to take. To accomplish a greatest to least value sort, make it LargestNumber - CurrentNumber. This means that you find the largest value, and this value becomes LargestNumber, and then for each element, Element.LayoutOrder = LargestNumber - ThisElementValue.

Setting it to LayoutOrder will allow you to retain semantic names, although it does have a Name sort option if you wish to use that as well, and then you just set the names to the order.

2 comments

0

I forgot to mention this is pretty much a leaderboard. So the player and their wins and displayed on a surface UI from greatest to least

0

This would do exactly that.

This discussion is preserved as it was. New answers, comments, and votes are closed.