力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 public ListNode sortInList (ListNode head) { // write code here ListNode cur = head; List<Integer> list = new ArrayList<>(); while (cur != null) { list.add(cur.val); cur = cur.next; } Collections.sort(list); ListNode fake = new ListNode(-1); ListNode last = fake; for (int i = 0; i < list.size(); i++) { ListNode node = new ListNode(list.get(i)); last.next = node; last = node; } return fake.next; }