本文介绍了如何在给定变量的Java中对列表进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Java中知道如何根据单个变量对列表对象进行排序. 例如: 假设我有
i want to know in java, how to sort the list object based on a single variable. ex: suppose i have
class student { string name; float avg; }我创建一个列表并传递对象int列表,现在我想对avg进行详细排序.
and i create a list and pass the object int list , now I want to sort the details on avg.
推荐答案请参阅此Java教程 [ ^ ]. <编辑>粘贴后应该检查链接.很遗憾,它缺少html中的"l". See this Java Tutorial[^]. <Edit> Should have checked the linked after pasting it. It was missing the ''l'' from html.
对不起,以上链接不再存在.认为Oracle已对其进行了更新: download.oracle/javase/tutorial/collections/algorithms/index.html 无论哪种方式,答案都位于Comparable或Comparator界面中. 干杯 sorry, the above link does not exist any more. Think Oracle have updated it : download.oracle/javase/tutorial/collections/algorithms/index.html Either way the answer lies in the Comparable or Comparator interface. Cheers
更多推荐
如何在给定变量的Java中对列表进行排序
发布评论