sorting fix
(cherry picked from commit 57f86f6)