Sort function bug fixed.