SHARE
TWEET

Untitled

a guest Feb 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from functools import reduce
  2.  
  3. list_in = [[], [67, 76, 89], [1, 12], [2, 4, 6, 8, 10, 11], [3, 5, 7]]
  4.  
  5. def sort(list_1, list_2):
  6.     index_1 = 0
  7.     index_2 = 0
  8.     list_out = []
  9.     while True:
  10.         if index_1 == len(list_1):
  11.             list_out.extend(list_2[index_2:])
  12.             break
  13.         if index_2 == len(list_2):
  14.             list_out.extend(list_1[index_1:])
  15.             break
  16.         if list_1[index_1] <= list_2[index_2]:
  17.             list_out.append(list_1[index_1])
  18.             index_1 += 1
  19.         else:
  20.             list_out.append(list_2[index_2])
  21.             index_2 += 1
  22.     return list_out
  23.  
  24. print(list(reduce(sort, list_in)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top