move sort to a module