Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Check if associations are the same, irrespective of key-value pair order
ResourceFunction["AssociationSameQ"][assoc1,assoc2, …] yields True if the associations are the same, up to reordering of key-value pairs. |
AssociationSameQ ignores the key-value orders and looks at the keys and values themselves:
In[1]:= | ![]() |
Out[1]= | ![]() |
Normal usage of SameQ yields False if the associations are not in the same order:
In[2]:= | ![]() |
Out[2]= | ![]() |
The order is also ignored for nested associations:
In[3]:= | ![]() |
Out[3]= | ![]() |
AssociationSameQ can take more than two associations:
In[4]:= | ![]() |
Out[4]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License