Answers for "sort array based on another array python"

2

sort two lists by one python

list1 = [3,2,4,1,1]
list2 = ['three', 'two', 'four', 'one', 'one2']
list1, list2 = zip(*sorted(zip(list1, list2)))
Posted by: Guest on October-15-2020
1

sort array based on another array

arr.sort((a, b) =>{  
	return sortingArray.indexOf(a) - sortingArray.indexOf(b);
});
Posted by: Guest on November-28-2020

Code answers related to "sort array based on another array python"

Python Answers by Framework

Browse Popular Code Answers by Language