Belzebub

bubble_sorting.lua

Mar 5th, 2021
710
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function DoCheck(tab, i1, i2, customcheck)
  2.     if tab[i1] and tab[i2] then
  3.         local b = customcheck(tab[i1], tab[i2])
  4.         tab[i1], tab[i2] = tab[b and i2 or i1], tab[b and i1 or i2]
  5.  
  6.         return true
  7.     end
  8.  
  9.     return false
  10. end
  11.  
  12. function table.BubbleSort(tab, customcheck)
  13.     for i = 1, #tab do
  14.         while DoCheck(tab, i, i + 1, customcheck) do
  15.             i = i - 1
  16.         end
  17.     end
  18.  
  19.     return tab
  20. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×