This article introduces an innovative approach to antenna array design, focusing on synthesizing the optimal radiation pattern for fifth-generation (5G) communication. The authors have designed a reliable linear and elliptical antenna array (EEA) of dipole elements by employing sailfish optimization (SFO). 5G technology promises transformative improvements in wireless communication with high data rates, expanded capacity, minimal latency, and exceptional service quality. The crux of 5G lies in the precision of antenna array design, aiming for an emission pattern with minimal side lobe levels (SLLs) and a narrow half-power beam width (HPBW). A narrower HPBW is essential for efficient long-range communication, whereas reducing the SLLs enhances signal clarity. The SFO optimizes the current excitation of each antenna element for reducing the mutual coupling effects and lowering the SLL and HPBW values in linear and EEAs. This paper uses the exact excitation to each element to show the linear antenna arrays (LAA) (10-, 16-element) design examples and EAA (8-, 12-, 20-element) structures. The LAA and EAA design examples obtained with the SFO algorithm establish the advancement in SLL suppression over the uniform antenna array and the methods proclaimed in the recent article.