Fixed reorder function.