5

I'm trying to sort an ArrayList in my Android app, but its throwing an exception. Here's the part of my code where it happens:

List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);  
Collections.sort(packs);

Does anybody have any ideas?

3
  • 1
    What kind of error? Post your logcat Commented Jul 19, 2011 at 6:58
  • 1
    Show us the error or exception you're getting. Commented Jul 19, 2011 at 6:58
  • Have you try to use in-built sort function? Commented Dec 14, 2011 at 10:31

3 Answers 3

3

packs contains PackageInfo objects, and sort can not find a natural order for those is my best guess. If you want to sort, use a Comparator with the sort which defines what you want to sort the PackageInfo objects on.

Sign up to request clarification or add additional context in comments.

Comments

2

sorting
another example
one more
this also
may above link helpful to you Happy Coding..:):) thanks Pragna

Comments

2

here is a simple example of How to sort array in android?.

String[] array = new String[]{"one","two","three","four"};
Arrays.sort(array);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.