-5

I have an ArrayList of Set of String in Java

List<Set< String >> combinations; 

What is the best way to order the ArrayList based on the size of the Set in an ascending order?

3

1 Answer 1

4

Write a Comparator<Set<String>> that compares the size() results from the two Set instances. Use the Collections.sort method that takes a Comparator as the second argument.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.