I have two list:
array1 = [1, 0, -1, 0, 0, 1,1, -1, 0, 1] array2 = [0, 1, -1]
I want to return another list based on how the second list is sorted for example the output of the two lists above would be
[0, 0, 0, 0, 1, 1, 1, 1, -1, -1]
this is what I currently have however only [0,0,0,0] print can anyone tell me what im doing wrong:
def patternSort(arr1, arr2):
counter = 0
i = 0
arr3 = []
while i < len(arr1):
if arr1[i] == arr2[counter]:
arr3.append(arr1[i])
i += 1
print(arr3)
array1 = [1, 0, -1, 0, 0, 1,1, -1, 0, 1]
array2 = [0, 1, -1]
patternSort(array1, array2)