add Glical.sort (+ move some pieces of code)