I am trying to achieve very complex kind of sort using django queryset.Its more like how your comments and your friends and family comments appears on top in facebook and youtube comment.
to breakdown, i am combining different queryset to same model achieve a result.
my_assinged_tasks = Tasks.objects.filter(to=request.user)
non_assigned_tasks = Tasks.objects.filter(to__isnull=True)
tasks_created_by_my_direct_supervisor = Tasks.objects.filter(**criteria)
suggested_todo_task = ##Some Complex Logic to detect what task are similar to my completed tasks
uncompleted_tasks = ## Criteria
tasks = my_assinged_tasks | non_assigned_tasks | tasks_created_by_my_direct_supervisor | suggested_todo_task | uncompleted_tasks
I want to sort it in order of
1 - tasks_created_by_my_direct_supervisor
2 - my_assinged_tasks
3 - uncompleted_tasks
......
the only solution i have in my mind is to create a dict and loop through each query set result individually and populate that dict accordingly which is very in efficient that way.
Is there a more efficient way of achieving this?