Android List<T> 排序
来源:互联网 发布:js创建html表格 编辑:程序博客网 时间:2024/06/06 09:13
1.T排序
List<GroupBean> groupBeans ;
Collections.sort(groupBeans,new Comparator<GroupBean>(){
public int compare(GroupBean arg0, GroupBean arg1) {return new Integer(arg0.sortno).compareTo(arg1.sortno);
}
});
Log.e("排序", u.sortno+" "+u.groupname);
}
2. 字符串
ArrayList list =
new
ArrayList();
list.add(
"92.8"
);
list.add(
"68.9"
);
list.add(
"168.61"
);
list.add(
"242"
);
list.add(
"317"
);
list.add(
"105"
);
// 字符串排序
Collections.sort(list);
System.out.println(list.toString());
// [105, 168.61, 242, 317, 68.9, 92.8]
//double排序
Collections.sort(list,
new
Comparator() {
@Override
public
int
compare(Object o1, Object o2) {
return
new
Double((String) o1).compareTo(
new
Double((String) o2));
}
});
System.out.println(list.toString());
// [68.9, 92.8, 105, 168.61, 242, 317]
}
阅读全文
0 0
- Android List<T> 排序
- C# List<T>排序
- List<T>排序
- Jquery List<T>排序
- List<T>排序
- List<T> 排序
- List<T> 排序
- List<T> 属性排序
- JAVA:List<T> 排序
- list<T>排列 排序
- 对List<T> 随机排序
- C# List<T>.Sort排序
- List<T> 查询 linq 排序
- List<T> 排序问题分享
- Linq 之 List<T> 排序
- List<T> 排序及筛选
- List<T>排序
- 对List<T> 随机排序
- how2j仿天猫前端
- caffe2 三: Basics of Caffe2
- 设计模式--抽象工厂模式
- linux利用shell实现守护进程的脚本
- 二 栈和队列的有关操作
- Android List<T> 排序
- Spring+SpringMVC+MyBatis 整合(一)(Maven配置)
- activeMQ学习笔记 -- day01介绍
- android页面跳转的几种方式
- ThreadLocal的用法
- 三 二叉树的基本操作
- linux运维面试题
- python的with语句和上下文管理器初窥
- Eloquent JavaScript 笔记 十二:Javascript and the Browser