<span style="font-family:Comic Sans MS;font-size:18px;">#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
template<typename T>
void swap1(T &a,T &b){
auto temp=a;
a=b;
b=temp;
}
template<typename T>
void duiSort(vector<T> &v){
int m=v.size();//m,容器大小
for(m;m>1;m--){
int node=m/2;//node,最后一个节点编号,从1开始
for(node;node>=1;node--){
int r=2*node+1;//r,右子元素存在,其编号
if(v[node-1]>v[r-2]) swap1(v[node-1],v[r-2]);
if((r<=m)&&(v[node-1]>v[r-1])) swap1(v[node-1],v[r-1]);
}
swap1(v[0],v[m-1]);
}
}
</span>