See the attached figure. The original triangle is shown in red (triangle ABC). The line of reflection is the blue dashed line. This is the equation y = x. Reflecting triangle ABC over the line y = x results in the purple triangle A'B'C'.
Note how the x and y values swap places. We have... point A = (5,1) turn into point A' = (1,5) point B = (8,1) turn into point B' = (1,8) point C = (8,6) turn into point B' = (6,8) The swap occurs because the rule (x,y) --> (y,x) tells this to happen.