This research proposes the dandelion optimizer (DO), a bioinspired stochastic optimization technique, as a solution for achieving maximum power point tracking (MPPT) in photovoltaic (PV) arrays under partial shading (PS) conditions. In such scenarios, the overall power output of the PV array is adversely affected, with shaded cells generating less power and consuming power themselves, resulting in reduced efficiency and local hotspots. While bypass diodes can be employed to mitigate these effects by redirecting current around shaded cells, they may cause multiple peaks, making MPPT challenging. Therefore, metaheuristic algorithms are suggested to effectively optimize power output and handle multiple peaks. The DO algorithm draws inspiration from the long-distance movement of a dandelion seed, which relies on the force of the wind. By utilizing this bioinspired approach, the DO algorithm can successfully capture the maximum power point (MPP) under different partial shading scenarios, where traditional MPPT algorithms often struggle. An essential contribution of this research lies in the examination of the performance of the proposed algorithm through simulation and real-time hardware-in-the-loop (HIL) results. Comparing the DO algorithm with the state-of-the-art algorithms, including particle swarm optimization (PSO) and cuckoo search (CS), the DO algorithm outperforms them in terms of power tracking efficiency, tracking duration, and the maximum power tracked. Based on the real-time HIL results, the DO algorithm achieves the highest average efficiency at 99.60%, surpassing CS at 96.46% and PSO at 94.74%. These findings demonstrate the effectiveness of the DO algorithm in enhancing the performance of MPPT in PV arrays, particularly in challenging partial shading conditions.