Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sort by index 2d array python

a = [[9, 9, 2], [9, 9, 3], [9, 9, 8], [9, 9, 4], [9, 9, 1], [9, 9, 5]]

b = sorted(a, key=lambda a:a[2])

#b contains the following arrays, sorted by their second index:
[[9, 9, 1], [9, 9, 2], [9, 9, 3], [9, 9, 4], [9, 9, 5], [9, 9, 8]]
Comment

PREVIOUS NEXT
Code Example
Python :: get current site django 
Python :: request url in web scraping 
Python :: django admin create superuser 
Python :: python upload video to youtube 
Python :: pandas drop unnamed columns 
Python :: how to save image opencv 
Python :: how to center plotly plot title 
Python :: unix to datetime python 
Python :: python gettext 
Python :: increase xlabel font size matplotlib 
Python :: plotly hide legend 
Python :: how to take array input in python in single line 
Python :: export image python 
Python :: python reimport module 
Python :: python subprocess.run output 
Python :: django import response 
Python :: generate a color python 
Python :: turn list to string with commas python 
Python :: how to delete last N columns of dataframe 
Python :: jupyter clear cell output programmatically 
Python :: Write a line to a text file using the write() function 
Python :: python MinMaxScaler() 
Python :: how to increase the figure size in matplotlib 
Python :: how to open a software using python 
Python :: numpy documentation 
Python :: put comma in numbers python 
Python :: install curses python 
Python :: tkinter give button 2 commands 
Python :: plt.plot width line 
Python :: pascal triangle python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =