I have an array of dates/objects in a dictionary:
task_list[d] = [tasks, pick]
where d is a date, tasks is a list of objects, and pick is an integer
I have another dictionary for overdue objects:
overdue_list={}
overdue_list['Overdue Tasks'] = [overdue_actions, 0]
If I added the overdue_actions to the task_list and sorted:
task_list['Overdue Tasks'] = [overdue_actions, 0]
total_task_list = SortedDict( sorted( task_list.items() ) )
I'd get all of the dictionary keys in chronological order followed by "Overdue Task". But I actually want to list "Overdue Task" first, followed by the dates in chronological order.
Is there a way for me to add the following two dictionaries together into a SortedDict?
overdue_list['Overdue Tasks'] = [overdue_actions, 0]
task_list = SortedDict( sorted( task_list.items() ) )
I want a total_task_list such that the "Overdue Tasks" is first in the sorted dictionary, followed by the dates in task_list in chronological order.
Django SortedDict support insert
. You can:
total_task_list = SortedDict( sorted( task_list.items() ) )
# And then:
total_task_list.insert(0, 'Overdue Tasks', [overdue_actions, 0])
this way you will have "Overdue Task" as first item in total_task_list
.