How do I sort a multidimensional table in Lua?
问题 I have a table consisting basically of the following: myTable = {{1, 6.345}, {2, 3.678}, {3, 4.890}} and I'd like to sort the table by the decimal values. So I'd like to the output to be: {{2, 3.678}, {3, 4.890}, {1, 6.345}} If possible, I'd like to use the table.sort() function. Thankyou in advance for the help :-) 回答1: Given that your table is a sequence, you can use table.sort directly. This function accepts a comparison predicate as its second argument, which prescribes the comparison