Lua语言实现7种排序(冒泡排序,插入排序,选择排序,快速排序,归并排序,堆排序)
冒泡排序function BubbleSort(arr) local len = #arr; for i = 1,len do for j = 1,len-i do if (a[j] < a[j+1]) then a[j],a[j+1] = a[j+1],a[j]; end end endend插入排序function InsertSort(arr) local len = #arr for i = 2,len do local temp = arr