Skip to content

Instantly share code, notes, and snippets.

@kwekuboateng
Created October 13, 2016 22:58
Show Gist options
  • Save kwekuboateng/bf65dbec671410f6a458718e03b6a064 to your computer and use it in GitHub Desktop.
Save kwekuboateng/bf65dbec671410f6a458718e03b6a064 to your computer and use it in GitHub Desktop.
def sorting_nums(item):
item = sorted(item)
len_item = len(item)
middle = len_item // 2
new_item = []
for i in range(middle):
new_item.append(item[i])
new_item.append(item[-1-i])
if len_item % 2 == 1:
new_item.append(item[middle])
return new_item
a = [1,5,4,6,7,2,3]
print(sorting_nums(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment