Ok, I figured out the issue. I need to get to bed, but I'll try and upload the fixed version over the weekend (need to double check something before I do). It was a problem with how I optimized my bubble sort, which compares the top 12 bits for the note position. The signed bit gets flipped on, resulting in high numbers being turned negative, and sorted before the first note in the pattern.