Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Sort expressions by depth and leaf count
ResourceFunction["DepthLeafCountSort"][list] sort a List of expressions list by depth and leaf count. |
Sort a List of expressions by depth and leaf count:
In[1]:= | ![]() |
Out[1]= | ![]() |
Generate a List of expressions:
In[2]:= | ![]() |
Out[2]= | ![]() |
Show the tree forms of the expressions:
In[3]:= | ![]() |
Out[3]= | ![]() |
Sort by depth and leaf count:
In[4]:= | ![]() |
Out[4]= | ![]() |
Sort sorts first by length, then based on lexicographic ordering:
In[5]:= | ![]() |
Out[5]= | ![]() |
DepthLeafCountSort sorts first by Depth then LeafCount:
In[6]:= | ![]() |
Out[6]= | ![]() |
Generate a List of expressions:
In[7]:= | ![]() |
Out[7]= | ![]() |
Sort uses a lexicographic ordering:
In[8]:= | ![]() |
Out[8]= | ![]() |
DepthLeafCountSort orders expressions by their depth and then by their leaf count:
In[9]:= | ![]() |
Out[9]= | ![]() |
An equivalent ordering using SortBy:
In[10]:= | ![]() |
Out[10]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License