Function Repository Resource:

# DropSmallestBy

Drop the smallest values from a list based on a function

Contributed by: Sander Huisman
 ResourceFunction["DropSmallestBy"][list,f,n] drops the n elements ei from list for which f[ei] is smallest. ResourceFunction["DropSmallestBy"][f,n] represents an operator form of ResourceFunction["DropSmallestBy"] that can be applied to an expression.

## Examples

### Basic Examples (3)

Drop the smallest two values determined by their magnitude:

 In[1]:=
 Out[1]=

Drop the smallest two complex values determined by their magnitude:

 In[2]:=
 Out[2]=

Use the operator form, by first creating an operator op:

 In[3]:=
 Out[3]=

Apply the operator:

 In[4]:=
 Out[4]=

### Scope (2)

When n=0, nothing is deleted:

 In[5]:=
 Out[5]=

A negative number deletes the largest n numbers:

 In[6]:=
 Out[6]=

### Properties and Relations (2)

If n is larger than the length of the list, an empty list is returned:

 In[7]:=
 Out[7]=

DropSmallestBy and TakeSmallestBy are complementary:

 In[8]:=
 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

SHuisman

## Version History

• 1.0.0 – 02 April 2020