def quick_sort(a, l, r)
return if l >= r
pivot = a[l]
ll = l
rr = r
loop do
ll += 1 while a[ll] < pivot
rr -= 1 while a[rr] > pivot
break if ll >= rr
a[ll], a[rr] = a[rr], a[ll]
ll += 1
rr -= 1
end
quick_sort(a, l, rr)
quick_sort(a, rr + 1, r)
end
data = [4,2,82,8,3,-5,11,4,6,22]
quick_sort(data, 0, data.size - 1)
p data
ZGVmIHF1aWNrX3NvcnQoYSwgbCwgcikKICByZXR1cm4gaWYgbCA+PSByCgogIHBpdm90ID0gYVtsXQogIGxsID0gbAogIHJyID0gcgogIGxvb3AgZG8KICAgIGxsICs9IDEgd2hpbGUgYVtsbF0gPCBwaXZvdAogICAgcnIgLT0gMSB3aGlsZSBhW3JyXSA+IHBpdm90CgogICAgYnJlYWsgaWYgbGwgPj0gcnIKCiAgICBhW2xsXSwgYVtycl0gPSBhW3JyXSwgYVtsbF0KICAgIGxsICs9IDEKICAgIHJyIC09IDEKICBlbmQKCiAgcXVpY2tfc29ydChhLCBsLCBycikKICBxdWlja19zb3J0KGEsIHJyICsgMSwgcikKZW5kCgpkYXRhID0gWzQsMiw4Miw4LDMsLTUsMTEsNCw2LDIyXQpxdWlja19zb3J0KGRhdGEsIDAsIGRhdGEuc2l6ZSAtIDEpCnAgZGF0YQ==