Sort:  

.

Ok, that must be the ultimate source of my misunderstanding. I'll have to check the code more carefully in the future.