The partial shading on photovoltaic (PV) modules causes a reduction in generated power and multiple peak points in their electrical characteristics. If the number of shaded modules of two or more rows are different then electrical characteristics exhibit multiple peaks. Also, as the number of shaded modules in a row increases the generated power decreases. These two observations are the main idea of this paper. The algorithm proposed in this paper redistributes shaded modules to various rows such that each row gets the lowest possible number of shaded modules and thereby increases the generated power. This work discusses a condition to achieve an equal number of shaded modules in all rows for which there is only one peak in the electrical characteristics. For the case where this condition is not satisfied, there can only be two-row groups with a different number of shaded modules. However, each group is having the same number of shaded modules and so only two peaks in the electrical characteristics. The proposed algorithm is applicable to any mxn structure of PV arrays. Extensive simulations are carried out and the performance of the proposed algorithm is compared with existing methods for various shading patterns. The results show that the proposed method gives minimum power loss, better performance ratio, and a lesser number of peak points. INDEX TERMS Maximum power generated, partial shading loss, performance ratio, reconfiguration, total cross tied configuration.