The whale algorithm is proposed to optimize the orderly charging of electric vehicles. Considering the user"s charging demand and the grid load level, the optimal charging start time of electric vehicles connected to charging piles is calculated to achieve orderly charging of large-scale electric vehicles, aiming at reducing the peak charging load. The validity of the algorithm is verified by simulating user"s charging demand. The results show that the optimized ordered charging method can achieve the optimization goal of peak load reduction and valley filling compared with disordered charging.