I suspect the issue is with null entries in the records list. This just nukes them all before processing with sorting. I looked over all of the list accesses, and they didn't appear to be index controlled, so this shouldn't break anything.