Transcriptomics and metabolomics, two biological research fields that need large numbers of zebrafish embryos, require the removal of unfertilized or nonviable zebrafish embryos. Biologists routinely conduct the tedious, error-prone, and time-consuming manual sorting of embryos. We suggest a novel approach that combines deep learning and microfluidics for automated sorting to overcome this difficulty. To determine the developmental stage and viability of zebrafish eggs, we trained an optimized YOLOv5 model with 95.8% accuracy and a processing speed of 10.6 ms per frame, classifying them as dead, unfertilized, or alive. The eggs are contained in traps on a microfluidic chip using micro-pumps. After that, the deep learning system can identify and automatically sort the eggs according to their viability by positioning this chip on an XYZ motorized stage. The sorting experiment was conducted in two modes: without feedback and with feedback while using the dead egg position. The first one had a sorting success rate of 90% as opposed to 97.9% for the feedback mode with 3 seconds required for each dead egg. This automated approach provides a precise and efficient way to handle a large number of zebrafish embryos while also greatly reducing the workload associated with manual sorting. The success rates attained demonstrate the usefulness and effectiveness of our suggested methodology, opening new avenues for biological research involving accurate embryo selection.