首页 > 编程语言 >java8排序stream().sorted()

java8排序stream().sorted()

时间:2023-02-08 17:24:15浏览次数:40  
标签:Comparator stream Student 升序 sorted 排序 java8

默认升序

 

先以年龄升序排序

年龄相同是 按分数降序

List<Student> list= userList.stream().sorted(Comparator.comparing(Student::getAge).thenComparing(Student::getScore,Comparator.reverseOrder())).collect(Collectors.toList());

 

标签:Comparator,stream,Student,升序,sorted,排序,java8
From: https://www.cnblogs.com/fchhk/p/17102560.html

相关文章

  • java-Stream流的常用方法
    一 常见创建流的三种方式//list集合创建流方式newArrayList<>().stream();newHashSet<>().stream();//map集合创建流方式,原......
  • JDK8 Stream的使用
    借助Lambda表达式,可以简化集合类的操作。一、List 二、Set三、Map四、Array ......
  • RocketMQ Streams拓扑构建与数据处理过程
    本文作者:倪泽,ApacheRocketMQcommitter、RSQLDB/RocketMQStreamsMaintainer01背景RocketMQStreams1.1.0版本已于近期发布,相对之前版本有以下改进和优化:1、API层面支持......
  • GStreamer基础教程13 - 调试Pipeline
    摘要在很多情况下,我们需要对GStreamer创建的Pipeline进行调试,来了解其运行机制以解决所遇到的问题。为此,GStreamer提供了相应的调试机制,方便我们快速定位问题。 查......
  • GStreamer系列 - 基本介绍
    什么是Gstreamer?Gstreamer是一个支持Windows,Linux,Android,iOS的跨平台的多媒体框架,应用程序可以通过管道(Pipeline)的方式,将多媒体处理的各个步骤串联起来,达到预期的效果。......
  • GStreamer基础教程01 - Hello World
    摘要在面对一个新的软件库时,第一步通常实现一个“helloworld”程序,来了解库的用法。对于GStreamer,我们可以实现一个极简的播放器,来了解GStreamer的使用。 环境配置为......
  • GStreamer基础教程02 - 基本概念
    摘要在 Gstreamer基础教程01-HelloWorld中,我们介绍了如何快速的通过一个字符串创建一个简单的pipeline。为了能够更好的控制pipline中的element,我们需要单独创建eleme......
  • GStreamer基础教程03 - 媒体类型与Pad
    摘要在上一篇文章中,我们介绍了如何将多个element连接起来构造一个pipline,进行数据传输。那么GStreamer是通过何种方式保证element之间能正常的进行数据传输?今天就将介......
  • c++ gstreamer使用2
    1,播放教程playbin#include<gst/gst.h>#include<stdio.h>/*Structuretocontainallourinformation,sowecanpassitaround*/typedefstruct_CustomData......
  • nginx 报错 upstream timed out (110: Connection timed out)
    upstreamtimedout(110:Connectiontimedout)whilereadingresponseheaderfromupstream, 在http下面加:  proxy_http_version1.1;  proxy_set_he......