Fix #958
Merge pull request #1012 from matheod/sortTemporary

Fix #958