Using an online high-throughput detection system for sorting oranges during the post-harvest process helped improve the commercialization level of the oranges industry. Surface defects on oranges created a poor first impression for consumers, making the rapid detection of oranges surface defects a primary concern for online sorting systems. However, due to variations in defect size and the visual similarity of different defects, there were still some challenges in detecting and identifying various surface defects on orange fruits based on their types. To address these challenges, this study first categorized surface defects on oranges into three major categories: deformity, scarring, and disease spot, based on their causes and potential post-harvest losses. Subsequently, to achieve real-time detection of orange surface defects on the orange sorting machine, a YOLOX-based real-time multi-type surface defect detection algorithm (MSDD-YOLOX) for oranges was proposed. This algorithm significantly improved the detection effectiveness of scarring at different scales by introducing neck network residual connections and cascading of the neck network. To address the issue of missed detections in texture-based defects and improve the regression of predicted bounding boxes, focal loss and Complete-IoU (CIoU) were employed in the algorithm. The results showed that MSDD-YOLOX achieved F1 values of 88.3 %, 80.4 %, and 92.7 % for the detection of deformity, scarring, and disease spot, respectively, with an overall detection F1 value of 90.8 %. These values represented improvements of 13.1 %, 10.2 %, 4.5 %, and 6.4 %, respectively, compared to the baseline model. Furthermore, compared to other deep learning object detectors, namely Faster RCNN, RetinaNet, FCOS, and Swin-Transformer, the proposed algorithm achieved optimal detection accuracy. Additionally, the MSDD-YOLOX model had a compact size of only 8.98 M, enabling real-time detection on the fruit grading line with an inference speed of up to 64.2FPS. Another innovation of this research was the external validation conducted on green oranges from Hainan and mandarins from Zhejiang. The results of external testing demonstrated that MSDD-YOLOX achieved overall F1 values of 90.6 % and 81.1 % for citrus fruits in these two regions, effectively proving the online deployment capability of MSDD-YOLOX and providing a robust solution for external defect detection in citrus fruits.