1.使用PageHelper排序(Pagehelper的版本需在5.1.2及以上)
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
其中A为排序依据的字段名,B为排序规律,desc为降序,asc为升序
或者一步到位
String orderBy="字段名 排序规律";
2.使用Mybatis排序
XXXExample example = new XXXExample();
example.setOrderByClause("字段名1 ASC/DESC,字段名2 ASC/DESC,...");