To improve the performance of reversible data hiding on JPEG images, a multi-level sorting prediction enhancement-based two-dimensional reversible data hiding algorithm for JPEG images is proposed in this paper. Firstly, the smoothness of each DCT block is evaluated by counting the location of the last non-zero coefficient in each DCT block. Then, the gradient of the object block is calculated with the DC coefficients of its surrounding blocks, and the lowest gradient direction blocks are employed to achieve the prediction of object block AC coefficients. Secondly, these gradient of adjacent blocks of the object block are compared to found the lowest gradient direction. The AC coefficient of the object block is accurately predicted by coefficients at the same position of its lowest gradient-direction adjacent blocks. Thirdly, the obtained DCT coefficient prediction errors are paired with a similar prediction-error pairing strategy to construct a two-dimensional prediction-error plane, and the secret data is imperceptibly embedded into the AC coefficients by using the two-dimensional histogram shifting algorithm. The performance of the proposed algorithm is evaluated on different datasets, and six representative images are involved in demonstrating its superiority. Extensive experimental results show that, compared to other state-of-the-art reversible data hiding algorithms, the proposed algorithm can achieve higher visual quality of the data-embedded image while maintaining low JPEG image file size increment.