我已经在我的代码中完成了排序,但我不想重新加载整个 json 结果,而是希望为我的 div 进行客户端重新排序。
我的 C# 订购代码是:
.OrderBy(p=> p.order == 0? int.MaxValue : p.order);
这给了我这样的结果
- 1
- 2
- 3
- 4
- 0
- 0
- 0
我的 HTML 架构就像
<div class="item" data-sort="0" id="5051fb7c746eed1bf05309db">
<span>Some values</span>
<span>Some values</span>
<div class="subgroups">
<div class="item" data-sort="null" id="5060de4a746eed1b44cc6e90"></div>
</div> <!-- closing subgroups -->
</div> <!-- closing main div which need to be sorted -->
<div class="item" data-sort="2" id="5051fb7c746eed1bf05309db">
<span>Some values</span>
<span>Some values</span>
<div class="subgroups">
<div class="item" data-sort="null" id="5060de4a746eed1b44cc6e90"></div>
</div> <!-- closing subgroups -->
</div> <!-- closing main div which need to be sorted -->
<div class="item" data-sort="0" id="5051fb7c746eed1bf05309db">
<span>Some values</span>
<span>Some values</span>
<div class="subgroups">
<div class="item" data-sort="null" id="5060de4a746eed1b44cc6e90"></div>
</div> <!-- closing subgroups -->
</div> <!-- closing main div which need to be sorted -->
我如何重新排序这些div
s,以便第二个成为第一个,而那些数据为 0 的将在重新排序时最后一个。