Go cheap and dirty then...
You know the object you want, all that is standing in the way are
existing Variants... so just kill 'em all, create your shiny new ones
and be done with it. Not exactly algorithmically pleasant, but that is
the reality of clunky API based computing. You do not need a doctorate
to see that fighting for computing efficiency is a losing cause. Any
API that moves the luxury closer to the end-user, probably incurs a
lot more complexity internal to their codebase, so they opt-out. You
get that in this issue of course. I see it all the time...
Ever examined some of the Liquid theme code floating around in front-
end shops. If you ever want to see some of the craziest nested looping
comparison structures, that world is your oyster. Trillions of CPU
cycles mercilessly slaughtered all in the name of easy-peasy
frictionless templating. But in the end, it kinda works...
Just revert to the old bubble sort when you have to, in other words.