Skip to content

Instantly share code, notes, and snippets.

@ugofred
Last active October 10, 2016 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugofred/12185d83ff5857792802e2568089fd90 to your computer and use it in GitHub Desktop.
Save ugofred/12185d83ff5857792802e2568089fd90 to your computer and use it in GitHub Desktop.
def lsp_range(lsp):
if len(lsp) == 1:
return [lsp[0]]
sm = lsp[0]
lg = lsp[0]
for i in lsp:
if i > lg:
lg = i
elif i < sm:
sm = i
return [sm, lg]
def nex_range(lsp_):
nulsp = lsp[:]
all_ = lsp_range(nulsp)
nulsp.remove(range_[0])
nulsp.remove(range_[1])
return lsp_range(nulsp)
def sort_asc_dsc(lsp):
nulsp = lsp[:]
midlsp = len(nulsp) / 2
sort_ = []
z = 0
while z < midlsp:
all_ = lsp_range(nulsp)
sort_.insert(midlsp + z, all_[1])
sort_.insert(z, all_[0])
nulsp.remove(all_[0])
nulsp.remove(all_[1])
z = z + 1
if len(nulsp) == 1:
sort_.insert(midlsp,nulsp[0])
else:
pass
return sort_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment