Fixed cache sort bug