i have an object, which has multiple values. one of its field is timestamp. While creating the object, i have converted the input string to timestamp.
DATETIME_FORMAT = '%d-%b-%y %H.%M.%S.%f %p'
class CustomObject:
def __init__(self, input_data):
entry_list = [entry.strip() for entry in input_data.split(',')]
self.field_one = entry_list[0]
self.field_two = entry_list[1]
self.field_timestamp = datetime.strptime(entry_list[2], DATETIME_FORMAT)
There is list of CustomObject
which I want to sort based on field_timestamp
. How would i do that?
I was looking at sorted
function but it takes in a lambda as an expression. In this case, i don't have an expression, i just have one field which i will be using to sort. how should it be done?