Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python sort multiple lists based on sorting of single list

# Example usage:
list_of_lists = [[4,5,1,3,2], ['s','n','a','k','e'], ['p','l','a','n','e']]
list(map(list, list(zip(*sorted(zip(*list_of_lists), key=lambda sublist_to_sort_by: sublist_to_sort_by[0])))))
--> [[1, 2, 3, 4, 5], ['a', 'e', 'k', 's', 'n'], ['a', 'e', 'n', 'p', 'l']]
# This is involved to explain. Best way to understand it is to test
#	the components of the function from the inside out. 
Comment

PREVIOUS NEXT
Code Example
Python :: create a dictionary from a list python 
Python :: get multiple inputs in python 
Python :: how to convert pdf to word using python 
Python :: position in array python 
Python :: what does json.loads do 
Python :: calculate mean median mode in python 
Python :: python cocktail sort 
Python :: split python strings into pairs & complete uneven pairs 
Python :: drop all unnamed columns pandas 
Python :: Determine the sum of al digits of n 
Python :: pygame get keypress code 
Python :: intellij python 
Python :: minmaxscaler python 
Python :: how to create a variable in python 
Python :: np append row 
Python :: column to int pandas 
Python :: django q objects 
Python :: python time sleep 
Python :: NumPy unique Example Get the unique rows and columns 
Python :: python make string one line 
Python :: django environment variables 
Python :: Triangle Quest 
Python :: legend matplotlib 
Python :: how to square root in python 
Python :: python download complete web page 
Python :: python install minio 
Python :: python virtual enviroment 
Python :: how to print upto 5 decimal places in python 
Python :: turn characters to alpgabetic numper python 
Python :: round tuple 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =