java集合排序 一行代码
@GetMapping(value="/test5") public R test5(){ List<MongoTest> mongoTests = Arrays.asList(new MongoTest("1a", 54, "tom", "4"), new MongoTest("4a", 24, "tom", "4"), new MongoTest("3a", 33, "tom", "4"), new MongoTest("22", 98, "tom", "4"), new MongoTest("5", 11, "tom", "4")); mongoTests.sort(Comparator.comparing(MongoTest::getId)); return R.ok().put("data", mongoTests); }
2.字符串集合排序 java.util 包
// 对月份里面的日期进行倒叙排列 Collections.sort(collect1); Collections.reverse(collect1);
⎛⎝官萧何⎠⎞一只快乐的爪哇程序猿;邮箱:1570608034@qq.com