Attached is a zip file containing a demo program and test data which demonstrates the problem. MDX files seem to add keys in the order they are created and doesn't appear to be performing any kind of compare or sort to find the proper location.
I spent today trying to track this down, but apparently didn't have enough Mt. Dew.
source and test data to prove problem