下面是一个简单的Lua实现的冒泡排序代码:
function bubbleSort(arr)
local len = #arr
for i = 1, len do
for j = 1, len-i do
if arr[j] > arr[j+1] then
arr[j], arr[j+1] = arr[j+1], arr[j]
end
end
end
return arr
end
local arr = {64, 34, 25, 12, 22, 11, 90}
print(table.concat(bubbleS