Skip to content

Instantly share code, notes, and snippets.

@Grumblesaur
Last active October 28, 2015 21:02
Show Gist options
  • Save Grumblesaur/1e43e71cffcdd376664b to your computer and use it in GitHub Desktop.
Save Grumblesaur/1e43e71cffcdd376664b to your computer and use it in GitHub Desktop.
Dropsort: Remove element of list if it is not at least as large as the maximum of the elements preceding it.
def d(l):
j=b=0;m=l[j];r=[]
for i in l:
(m,b)=[(m,0),(i,1)][i>=m]
if b>0:r+=[i]
j+=1
l[:]=r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment