added new tool for reordering matrices