Hi HSE
You're right. There are two problems with the "Sort" method.
The first relates to the translation to x64 in line 179, which does not affect the 32-bit code.
The second is bad one. In line 178, an indirection is missing when the sorted item is reinserted.
I compiled the x86 and x64 versions and they seem to be working correctly.
I also attached the project because while reading the code I made some changes to format it the way I'm used to, but your original code is perfectly fine.
Biterider