博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java中排序相关
阅读量:6897 次
发布时间:2019-06-27

本文共 1094 字,大约阅读时间需要 3 分钟。

hot3.png

1. Array

基础类型可以直接sort

Method Description
Arrays sort methods
Arrays.sort(pa); Sorts the elements of the array of a primitive type into ascending order using their natural ordering.
Arrays.sort(pafromto); Sorts the elements pa[from]...pa[to-1] of a primitive type. into ascending order.
Arrays.sort(oa); Sorts the elements of the array of an object type into ascending order, using the order defined by Comparable interface, which defines thecompareTo method. Note that many Java classes such as String (but notStringBuffer), Double, BigInteger, etc implement Comparable.
Arrays.sort(oafromto); Sorts the elements of the array, in the range from...to of an object type into ascending order.
Arrays.sort(oacomp); Sorts the elements of the array of an object type into ascending order, using the Comparator comp.
Arrays.sort(oafromtocomp); Sorts the elements of the array, in the range from...to of an object type into ascending order using the Comparator comp.

2. ArrayList, 基础类直接调用Collections.sort方法。创建的对象要实现Comparable或者Comparator.

 

转载于:https://my.oschina.net/u/138995/blog/175757

你可能感兴趣的文章
折腾Java设计模式之解释器模式
查看>>
设计模式命令模式(行为型)
查看>>
RN开发快速切换底部导航时react-native-swiper轮播图组件白屏
查看>>
sublime px -> rem sass
查看>>
瀑布流照片墙布局
查看>>
日常工具--渐变+找图+压缩图片
查看>>
《Redis开发与运维》慢查询分析 读书笔记
查看>>
学习仿饿了么遇到商品详情页的添加购物车按钮没有动画,$emit派发事件
查看>>
一些开发chrome插件用到的API总结
查看>>
Java集合(二)-LinkedList源码解析
查看>>
如何配置wamp后运行magento2
查看>>
python学习干货教程(15):迭代器和生成器
查看>>
Flutter之布局类Widget
查看>>
three.js性能优化
查看>>
Choerodon如何进行日志收集与告警
查看>>
Vue篇之vue 使用Jade模板写html,stylus写css
查看>>
spring web 项目启动过程分析
查看>>
《HelloGitHub》第 36 期
查看>>
裂变活动成功的前提:回报大于付出
查看>>
深入解析ES6中let和闭包
查看>>