// 1.8

public class text {
public static void main(String[] args) {
String s1 = "哈哈哈11,呵呵呵22,嘿嘿33,四44";
List<String> collect = Arrays.stream(s1.split(",")).sorted((str2, str1) -> {
Integer int1 = Integer.valueOf(str1.replaceAll("[^0-9]", ""));
Integer int2 = Integer.valueOf(str2.replaceAll("[^0-9]", ""));
return int1 - int2;
}).map(str -> str.replaceAll("[0-9]", "")) .collect(Collectors.toList());
System.out.println(collect);
}
} //1.7
public class text {
public static void main(String[] args) {
String s1 = "哈哈哈11,呵呵呵22,嘿嘿33,四44";
List<String> strings = Arrays.asList(s1.split(","));
Collections.sort(strings, new Comparator<String>() {
@Override
public int compare(String str1, String str2) {
return Integer.valueOf(str1.replaceAll("[^0-9]", "")) - Integer.valueOf(str2.replaceAll("[^0-9]", ""));
}
});
System.out.println(strings);
}
}

String字符串排序1.8 lamda表达式以及1.7自定义排序的更多相关文章

  1. C# - List.Sort()自定义排序方法

    本文通过示例介绍了C#中典型容器List.Sort()的自定义排序方法,进而引出了C#中自定义排序的核心接口及方法 项目地址:自定义Sort方法 - SouthBegonia's Github Lis ...

  2. php中usort自定义排序如何使用

    php中usort自定义排序如何使用 一.总结 一句话总结:多写一个规则函数,而这个函数的写法和普通函数一样,调用的时候规则函数用函数名的字符串. 1.用户自定义规则函数有哪三个? usort — 使 ...

  3. Python应用——自定义排序全套方案

    本文始发于个人公众号:TechFlow,原创不易,求个关注 今天的这篇文章和大家聊聊Python当中的排序,和很多高级语言一样,Python封装了成熟的排序函数.我们只需要调用内部的sort函数,就可 ...

  4. [LeetCode] Custom Sort String 自定义排序的字符串

    S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sort ...

  5. [Swift通天遁地]五、高级扩展-(14)扩展String快速计算字符串中的各种数学表达式

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  6. SQL、Linq、lamda表达式 同一功能不同写法

    一.SQL.Linq.lamda表达式 同一功能不同写法 SQL LINQ Lambda SELECT * FROM HumanResources.Employee from e in Employe ...

  7. [.net 面向对象程序设计进阶] (7) Lamda表达式(三) 表达式树高级应用

    [.net 面向对象程序设计进阶] (7) Lamda表达式(三) 表达式树高级应用 本节导读:讨论了表达式树的定义和解析之后,我们知道了表达式树就是并非可执行代码,而是将表达式对象化后的数据结构.是 ...

  8. Linq和Lamda表达式的简单处理方式

    一 什么是LINQ? LINQ即Language Integrated Query(语言集成查询),LINQ是集成到C#和Visual Basic.NET这些语言中用于提供查询数据能力的一个新特性. ...

  9. 解读ASP.NET 5 & MVC6系列(12):基于Lamda表达式的强类型Routing实现

    前面的深入理解Routing章节,我们讲到了在MVC中,除了使用默认的ASP.NET 5的路由注册方式,还可以使用基于Attribute的特性(Route和HttpXXX系列方法)来定义.本章,我们将 ...

随机推荐

  1. C# 释放资源的规范写法

    static class CSharp_3 { /* ---------------------------------------- * 以下学习资源的释放:IDispose和析构函数 * 1.ID ...

  2. 六)iframe 及父子页面之间获取元素、方法调用

    http://www.w3school.com.cn/tags/tag_iframe.asp father.html <!DOCTYPE html> <html> <he ...

  3. Strict Weak Ordering

    Description A Strict Weak Ordering is a Binary Predicate that compares two objects, returning true i ...

  4. C# 字符,字符串和文本处理。

    1. 字符: 在.net中 字符是表示成16为Unicode代码值.每个字符都是System.Char结构(一个值类型)的实例. public class StringTempte { public ...

  5. Linux中Consul集群部署

    分配三台虚拟机: 192.168.5.125 192.168.5.128 192.168.5.129 在每台虚拟机上创建  /usr/consul 文件件  命令: mkdir /usr/consul ...

  6. WPF 简洁的主界面

    用的是dev的TileLayouotControl控件. <dxwui:PageAdornerControl Header="" Padding="30" ...

  7. css3动画(animation)效果2-旋转的星球

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 读取xml文件内容到数据库

    前言 前言不搭后语·················· 内容 听某个大牛说他们的公司常常会涉及到从xml文件中读数据到写入到数据库,序列化的时候会遇到这这个问题,将要持久化的数据到xml文件存储起来, ...

  9. jvisualvm_使用jstatd连接远程linux应用

    [1]确定linux系统正确安装了ssh # sudo ps -e | grep ssh ①注意使用root,使用$会报如下错误: [appadmin@webcsuat2 ~]$ sudo ps -e ...

  10. [ActionScript 3.0] 运用Color类interpolateColor静态方法绘制渐变色

    以下类可直接作为文档类测试,效果如图: package { import fl.motion.Color; import flash.display.GradientType; import flas ...