Below is my implementation without using any in bulit methods. Time Complexity is O(n^2)
def weird_sort(lst1,lst2):
sorted_lst2=[]
sorted_lst1=[]
lst3=[i for i in lst1]
while len(lst1)>0:
_min=lst1[0]
for i in range(1,len(lst1)):
if lst1[i] <_min:_min=lst1[i]
sorted_lst2.append(lst2[lst3.index(_min)])
lst1.remove(_min)
sorted_lst1.append(_min)
return sorted_lst1,sorted_lst2
This function can be called as :
import numpy as np
array1 = np.array([[3,2,1],[2,1,3]])
array2 = np.array([[4,5,6],[7,8,9]])
for i,j in zip(array1,array2):
print(list(weird_sort(list(i),list(j))))
Output is as required:
[[1, 2, 3], [6, 5, 4]]
[[1, 2, 3], [8, 7, 9]]
Edit : Modify the function return a bit to get the output in whatever the format you need. Mine is not exactly what you wanted but this do can do the trick.
Hope this helps.
keyread about it