Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function DoCheck(tab, i1, i2, customcheck)
- if tab[i1] and tab[i2] then
- local b = customcheck(tab[i1], tab[i2])
- tab[i1], tab[i2] = tab[b and i2 or i1], tab[b and i1 or i2]
- return true
- end
- return false
- end
- function table.BubbleSort(tab, customcheck)
- for i = 1, #tab do
- while DoCheck(tab, i, i + 1, customcheck) do
- i = i - 1
- end
- end
- return tab
- end
RAW Paste Data