Software-defined network (SDN) is an architecture with a physical or conceptual central controller. This architecture separates data and control plane causing network flexibility, programmability, and manageability. A packet when is received by the forwarding element (FE) as the first packet of the flow is forwarded towards the controller in the packet-in message; then, the controller decides for all packets belonging to the flow. The controller imposes the rule for the flow to the FE; thus, the FE acts based on the matching rules with the ingress packet in the flow table. Routing can be done by considering performance metrics to improve entire network performance in SDN. Performance and cost metrics include utilization, delay, jitter, packet loss ratio (PLR), blocking probability (BP), and link cost, so an optimized path selection is a multi-objective optimization problem and NP-Hard that we will consider. In this paper, we try to provide a comprehensive algorithm for optimizing the entire network performance in SDN. We propose the novel algorithm for flow routing based on three steps: (1) a linear algorithm is developed to extract the path between each source and destination in the controller, (2) non-dominated ranking is used to categorize the extracted paths, and finally, (3) the crowd distance sorting algorithm is implemented to select the optimized route from all performance dimensions. To evaluate the proposed algorithm, the shortest path and greedy-based routing algorithms will be simulated by Java, and the simulation results show that the proposed optimization algorithm improves the all mentioned performance criteria, simultaneously.