diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-10-21 16:39:05 -0500 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-10-21 16:39:05 -0500 |
commit | 5fb22327eeeb230328dca8b7016e36a1c9aad740 (patch) | |
tree | eb46860eb99a472ad645b312a4437c8942337a3e /core/variant/variant.h | |
parent | 5e65747d90411d58da46dd1a0dd0385280ff57ac (diff) | |
parent | 610635e1c8d8940397723052088979d16aa30a40 (diff) | |
download | redot-engine-5fb22327eeeb230328dca8b7016e36a1c9aad740.tar.gz |
Merge pull request #97542 from AThousandShips/dict_sort_fix
[Core] Fix sorting of `Dictionary` keys
Diffstat (limited to 'core/variant/variant.h')
-rw-r--r-- | core/variant/variant.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/variant/variant.h b/core/variant/variant.h index c76b849abd..3b1924e8ea 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -854,6 +854,19 @@ struct StringLikeVariantComparator { static bool compare(const Variant &p_lhs, const Variant &p_rhs); }; +struct StringLikeVariantOrder { + static _ALWAYS_INLINE_ bool compare(const Variant &p_lhs, const Variant &p_rhs) { + if (p_lhs.is_string() && p_rhs.is_string()) { + return p_lhs.operator String() < p_rhs.operator String(); + } + return p_lhs < p_rhs; + } + + _ALWAYS_INLINE_ bool operator()(const Variant &p_lhs, const Variant &p_rhs) const { + return compare(p_lhs, p_rhs); + } +}; + Variant::ObjData &Variant::_get_obj() { return *reinterpret_cast<ObjData *>(&_data._mem[0]); } |