move reordering function to wrappers module