reorder similarity matrix