在java 8中排序2次并按值排序

问题描述

我有人员列表和任务列表以及 timetoFinishTask

示例:人 => P1,P2,P3

任务 => T1,T2,T3,T4

一个人可以同时处理 2 个任务。

案例 1:

List<Person> persons = new ArrayList<>();
List<Task> tasks = new ArrayList<>();
    P1 -> T1 -> 1,P1 -> T2 -> 7
    P2 -> T3 -> 6
    P3 -> T4 -> 2

 Here 1,7,6,2 represent the time he takes to finish task in mins

 Since P1 has 2 tasks,his time to take up the next task would be max(1,7) and so the sorting 
 order must be output : List<Task> = [T4,T1,T2];

如果没有人有超过 1 个任务,则排序顺序将仅基于 timetoFinishTask

情况 2:

    P1 -> T1 -> 1,P2 -> T2 -> 7
    P3 -> T3 -> 6
    P4 -> T4 -> 2

    In this case (as no person has more than 1 task simultaneously) it will be sorted like  
    T1,T4,T2

我尝试使用 List>,我已经将人员任务时间放在一起

  class PersonTaskWrapper{
       String personName;
       Task task;    
  }

对于情况 2,它工作正常。但是我发现很难对一个人可以有 1 个以上任务的情况 1 进行排序,因此我必须先对一个人的常见任务排序(两次)一次,然后再将它与其他任务排序。 有什么简单的方法可以做到这一点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)