In Android, I have a Set, and I want to turn it into a sorted List.
How to do it with Collections.sort()?
protected List<PackageInfo> doInBackground(Void... params) {
Set<PackageInfo> adPackages = new HashSet<PackageInfo>();
//ArrayList<PackageInfo> adPackages = new ArrayList<PackageInfo>();
[..............]
return new ArrayList<PackageInfo>(adPackages);
//return adPackages;
}
List has a constructor which allows you to create it using any Collection. Then use the Collections.sort(List list) method.
E.g.
Cheers.