Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sort list of string datetimes python

import datetime
d = ['09-2012', '04-2007', '11-2012', '05-2013', '12-2006', '05-2006', '08-2007']
sorted(d, key=lambda x: datetime.datetime.strptime(x, '%m-%Y'))
Comment

PREVIOUS NEXT
Code Example
Python :: python csv dictwriter 
Python :: convert files from jpg to png and save in a new directory python 
Python :: python sum attribute in list 
Python :: notify2 python example 
Python :: how to change the window colour in pygame 
Python :: for each value in column pandas 
Python :: install biopython in windows 
Python :: concat dictionary of dataframes 
Python :: vsc python close all functions 
Python :: how to print an input backwards in python 
Python :: filter for a set of values pandas dataframe 
Python :: django not saving images forms 
Python :: how to calculate mean in python 
Python :: python dict order a dict by key 
Python :: how to clear command prompt python 
Python :: pyspark take random sample 
Python :: how to remove python3 on mac 
Python :: how to receive user input in python 
Python :: python how to remove the title of the index from dataframe 
Python :: python reduce function to sum array 
Python :: change each line color as a rainbow python 
Python :: data science standard deviation 
Python :: flask make static directory 
Python :: pytorch save model 
Python :: how to sort list in descending order in python 
Python :: check if user has manage messages discord.py 
Python :: list count frequency python 
Python :: windows alert python 
Python :: where my python modules 
Python :: pythion code for finding all string lengths in a code 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =