<h3><a title="题目描述" href="https://leetcode-cn.com/problems/insertion-sort-list/">题目描述</a></h3>
![file](https://i.loli.net/2020/11/20/V1tog2H8RUpTqLJ.png)
<h4>方法一</h4>
```java
class Solution {
public ListNode insertionSortList(ListNode head) {
if(head==null||head.next==null){
return head;
}
ListNode dummy = new ListNode(-1);
dummy.next = head;
ListNode tail = head;
ListNode cur = head.next;
while(cur!=null){
if(cur.val >= tail.val){
tail = tail.next;
}else{
ListNode prev = dummy;
while(prev.next.val<=cur.val){
prev = prev.next;
}
tail.next = cur.next;
cur.next = prev.next;
prev.next = cur;
}
cur = tail.next;
}
return dummy.next;
}
}
```
## 思路
- 链表问题设置**哑节点**很重要
- **取cur = tail.next的思想一时半会也没想到,积累经验吧**
今天氪金冲会员了,要赚回来呀!
![file](https://i.loli.net/2020/11/20/Rv6VaDmFh7ZSXbl.png)
Leetcode147 对链表进行插入排序 (氪金计划启动)