However, if you’d like to achieve that result, you could do something like this instead:
local SortedTable = UnsortedTable
return Value1 > Value2
By the way, when I first posted this I made a mistake (which I already fixed now). Remember to set the table that is used in table.sort's first argument to SortedTable, not UnsortedTable (just like in the script above).
Tables are not implicitly copied with the assignment operator, so doing local SortedTable = UnsortedTable will only create a variable SortedTable that is a direct reference to UnsortedTable. You can just pass the single variable to table.sort
For copying the unsorted table, you would have to do a shallow copy like this:
local SortedTable = table.pack(table.unpack(UnsortedTable))
Right. I didn’t realize that you were storing tables in the table. That also means the shallow copy example in my previous reply wouldn’t work as you would need a deep copy, but it doesn’t matter anyways because you don’t need that.