Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
Faeyll 22
5 years ago

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.

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 gmatchOnRoblox 103 — 5y
0
This would do exactly that. Faeyll 22 — 5y
Ad

Answer this question