Sort elements in range
[first,last)
into ascending order.
The elements are compared using operator<
for the first version, and comp for the second.
Equivalent elements are not guaranteed to keep their original relative order (see stable_sort).
来源: <http://www.cplusplus.com/reference/algorithm/sort/?kw=sort>
调用sort,引用头文件:#include <algorithm>
调用less(从小到大),greater(从大到小),引用头文件:#include <functional>
同时对于char等类型排序也是可以的。
时间: 2024-10-13 02:32:10