get_format relies on the order that .find processes the hash to find the first entry to use. So the order of the hash which is insertion order matters.
There is a problem with Puppet::Pops::Type::StringConverter.sort_formats its passed an array which it sorts based on assignablity and rank order. This method on Ruby is not consistent in the order of the hash it ends up creating.
I had it process 3 entries from in the array, in the normal order and reverse order and then printed out the values:
The array's after sorting look like this. These arrays should be sorted in the same order:
I think there are a couple issues with this part of the code:
Why do we ignore the rank if any one of the key's has a rank of 0?
Do we want a sort of this instead? where we use the rank if one of them is set and reverse the rank comparison so that high ranked items are higher?
Or should we be only using the a.to_s <=> b.to_s check when the ranks match