Wrong table sorting

  1. What do you want to achieve? the script print
    [1] = 2
    [2] = 3
    [3] = 4
    [4] = 5

  2. What is the issue? but he Print this
    ERROR

script

local Tab = {2,3,4,5}

table.sort(Tab)

print(Tab)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I look but this But there is no such request.

2 Likes

You are printing out the table as you have displayed above instead of iterating through the table using for loops,

hence why it’s printing out the table name rather than the values in the table.

1 Like

That usually only happens when you do this:

print(tostring(Tab))

Which more so prints the “Id” of the table.

It should normally print out this:

{...} or {}

Not nessacarly.

1 Like

Will print what you show…

for k, v in pairs(Tab) do print(string.format('[%d] = %s', k, v)) end

Will print just the values in a series…

print(unpack(Tab))
1 Like

That doesnt seem nessacary, Table that are printed in the output already do this.

-- The Timestamp is just the time I printed this, Ignore it if you want.
21:54:13.777   â–Ľ  { -- Opened Table
                    [1] = 2,
                    [2] = 3,
                    [3] = 4,
                    [4] = 5
                 }  -  Edit

21:54:13.777   â–¶ {...}  -  Edit -- Closed Table
21:54:13.777      {}  -  Edit    -- Empty Table
1 Like

Almost everything is like that but there is one problem yes and I have a lot of questions but not now Here is the problem

ERROR1
i need this only
[1] = 2
[2] = 3
[3] = 4
[4] = 5
And there is a way not to write all this and more? It’s terribly inconvenient.

1 Like

You just simply print the table, it doesnt make sense as to why you are getting the name of the table.

1 Like

This is very strange because on the Internet I saw a script where it already worked
ERROR2
And this is the result
:arrow_forward: {…} - Edit
[1] = 6
[2] = 3
[3] = 9
[4] = 7

1 Like

Ok, so I think I know why you are getting this, try clicking on the 3 dots on the Output, and Disable Log Mode, that may be why you are getting this.
Screenshot (17)

4 Likes

Honestly, I did not expect an error here, I have a question why It was here that there was an error

1 Like

All it really does is to “Simplify the Output” according to the Output Documentation

And It isnt an error, Its just an Option you can Enable / Disable.

1 Like

Good to know for the future thanks for the help!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.