Roblox List Layout Sort By Name not working as should

Alrighty! So its like it works 100% but not how I want it to be. So lets say I have a list of text labels numbered 5-15 ok now how Roblox sorts it is like this

1 = 1
10 = 2
11 = 3
12 = 4
13 = 5
14 = 6
15 = 7
2 = 8
3 = 9
4 = 10
5 = 11
6 = 12
7 = 13
8 = 14
9 = 15

you see the numbers on the left side of the “=” are how roblox sorts it I want it like on the right side. Here are a few images:
image
I want it to be numbered from the lowest to the highest from top to bottom. This is how much I can explain now to what I think can happen:
What I think is what if use alphabets? but idk how so ya.

The list does not respect number reading right-to-left. Remember it’s always left-to-right. So you have to use 001, 010, 100, etc.

Sort by LayoutOrder instead and set each frame’s LayoutOrder property to the number after 'Msg: '.

1 Like

A thing is that when I recreate a msg with the same name. and delete the old one it appears at the bottom whilst it should appear where the original message was.

Are you using #ScrollingFrame:GetChildren() in order to determine the msg’s number and/or LayoutOrder? Because if so then that won’t work.

If you delete a message and then want that message’s slot to be occupied the next time a message is created you’re going to need to locate that empty slot.

local function FindSlot()
	for Index = 1, 100 do
		local Slot = ScrollingFrame:FindFirstChild("Message"..Index)
		if not Slot then return Index end --Finds the first vacant slot.
	end
end

If you want to find the last vacant slot then you can simply perform the inverse of this iteration (iterate backwards instead of forwards).

1 Like

No I am not I am making it so that when ever I message is sent it increases the msg value by 1

I think u didnt understood the problem good. The problem is that if a number in greater than 9 it puts the 10 message and on after the first msg aka msg: 1 so
msg: 1 then msg: 10 I dont want that i want it like msg: 1, msg:2, msg:3 and so on!

I think you missed this reply.

It’ll order objects in the order that you desire, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10…
Not 1, 10, 2, 3, 4, 5, 6, 7, 8, 9…

https://developer.roblox.com/en-us/api-reference/property/UIGridStyleLayout/SortOrder

oh ok i will test it tomorrow cuz rn cant.

please tell me in depth! make it like a proper script!

I dont understand what you mean!

As I mentioned earlier, use 001, 010 and 100. The left-to-right reading is what makes the orders different. Since it’s only in the double digits:

01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16

Do not convert these into numbers or else they’ll remove the left-most zeroes if no other number occupies.

ok so HOW? like how would I make it?

Each time you add a number, format it.
string.format("%02d", number)

so i edited it

local number = 112
print(string.format("%02d", tostring(number):reverse()))

prints 211 is that good? and 100 becomes 01 1 also becomes 01

I don’t think you need the :reverse() call there.

if i dont the string does NOT change at all! its equal to print(number)

the thing is that the number could be any big number even infinite! and it only works for 1 digit numbers so should i change the 2 to a higher and HIGHER number?

I just tried it in studio:

print( string.format(“%02d”, tostring(1)) ) -- outputs 01

yea I know it works now Ig i gave the wrong number. (lol) let me see if it works with list layout.