首页 > 其他分享 >List排序

List排序

时间:2023-06-27 10:00:02浏览次数:32  
标签:倒序 valueOf List getCourseDuration Integer 排序

List排序

//按照某个字段进行正序排序
list.sort((x,y) ->Integer.compare(Integer.valueOf(x.getCourseDuration()),Integer.valueOf(y.getCourseDuration())));
//按照某个字段进行倒序排序
list.sort((x,y) ->Integer.compare(Integer.valueOf(y.getCourseDuration()),Integer.valueOf(x.getCourseDuration())));

//按照时间正序排序
studentList.stream().sorted(Comparator.comparing(Student::getCreateTime)).collect(Collectors.toList());
//按照时间倒序排序
studentList.stream().sorted(Comparator.comparing(Student::getCreateTime).reversed()).collect(Collectors.toList());

标签:倒序,valueOf,List,getCourseDuration,Integer,排序
From: https://www.cnblogs.com/striver20/p/17507848.html

相关文章

  • 【算法】根据整数数组,生成正的素因子二位数组,并排序
    给定一个正整数或负整数的数组,I=[i1,..,in] 生成一个形式为的排序数组P [[p,I数组的所有ij的和,其中p是ij的素因子(p为正)]…]P将按素数的递增顺序进行排序。 示例:I={12,15};//结果=“(212)(327)(515)”[2,3,5]是I的元素的所有素因子的列表,因此是结果。 注意事项: 如果某些数字为......
  • 织梦 channelartlist 支持 limit 属性使用
    查找字段:$attlist='typeid|0,row|20,cacheid|';替换为:$attlist='typeid|0,row|20,cacheid|'; 效果图: 在“$dsql->SetQuery”前面添加$limit=trim(preg_replace('#limit#is','',$limit));if($limit!='')$limitsql="L......
  • 29.归并排序
    研究了这么多算法以后,小桂子颇有收获,基本自认为排序算法已经全部掌握,于是就想卖弄一下自己的“算法内功”,另一方面为了交流推广,把这些算法传播出去,就召开一个全国算法大赛,集思广益,征集更牛逼的算法!在算法大赛上,有两位白发葱葱的老者提出的算法让小桂子自惭形秽,感叹良多。。。其......
  • 取list中某一段连续元素
    importjava.util.List;publicclassListUtils{/***取list中某一段连续元素**@paramlist*@parambeginIndex*@paramendIndex*@return*/publicstatic<T>List<T>fetchElementFromList(List<T>lis......
  • 34. 在排序数组中查找元素的第一个和最后一个位置
    给你一个按照非递减顺序排列的整数数组nums,和一个目标值target。请你找出给定目标值在数组中的开始位置和结束位置。如果数组中不存在目标值target,返回[-1,-1]。你必须设计并实现时间复杂度为O(logn)的算法解决此问题。示例1:输入:nums=[5,7,7,8,8,10],target=......
  • Arrays.asList()与Collections.unmodifiableList()
    java.util.Arrays#asList返回的是在Arrays实现的ArrayList,privatestaticclassArrayList<E>extendsAbstractList<E>implementsRandomAccess,java.io.Serializable{privatestaticfinallongserialVersionUID=-2764017481108945198L;......
  • 28.希尔排序
    插入排序虽好,但是某些特殊情况也有很多缺点,比如像下面这种情况:169前的元素基本不用插入操作就已经有序,元素1和2的排序几乎要移动数组前面的所有元素!!!于是,有个老帅哥就提出了优化此问题的希尔排序!希尔排序是希尔(DonaldShell)于1959年提出的一种排序算法。希尔排序也是......
  • IPList.cshtml
    @{ViewData["Title"]="IPList";Layout="~/Views/Shared/_Layout_layui.cshtml";}@sectionCss{}<divclass="demoTablelayui-form"style="padding:10px;background-color:#D4E7F0;">......
  • LLM-Blender:大语言模型排序融合框架
    随着Alpaca,Vicuna,Baize,Koala等诸多大型语言模型的问世,研究人员发现虽然一些模型比如Vicuna的整体的平均表现最优,但是针对每个单独的输入,其最优模型的分布实际上是非常分散的,比如最好的Vicuna也只在20%的任务里比其他模型有优势。有没有可能通过集成学习来综合诸多开源的「......
  • IPListController
    usingMicrosoft.AspNetCore.Http;usingMicrosoft.AspNetCore.Mvc;usingPT.BLL;usingPT.Common;usingPT.Model;usingPT.Web.Mvc.App_Start;usingSystem;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Linq;usingSystem.Text;usingSyst......