Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generalize Ordering by giving alternative orderings if there are equal items
ResourceFunction["EquivalentOrderings"][list] return a list of all possible orderings of list considering the permutations of equal items. | |
ResourceFunction["EquivalentOrderings"][list,n] return a list of all possible orderings of list considering the permutations of equal items, and limit each ordering to n items. |
Find the two ways of ordering this list:
In[1]:= |
Out[1]= |
If the orderings are limited to the first two elements, then there is only one way of ordering the list:
In[2]:= |
Out[2]= |
EquivalentOrderings will work on the same non-numeric values as Ordering:
In[3]:= |
Out[3]= |
Compare with Ordering:
In[4]:= |
Out[4]= |
Finding all possible orderings of a list of probabilities is helpful for considering alternative Huffman codes:
In[5]:= |
Out[5]= |
This work is licensed under a Creative Commons Attribution 4.0 International License