Link to home
Start Free TrialLog in
Avatar of coder-rl
coder-rl

asked on

How to sort a arraylist<string> by the string length of the entries?

The list has these entries:

engine
engine oil
engine cylinder
engine belt
engine valve
car
car light
car doors

in any order.

How to sort them into a list with the longest string the first element in the list?

Thanks,

coder-rl
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of coder-rl
coder-rl

ASKER

Hi Alex,

How to resume the original collection.sort behavor?

Thanks for showing how to instruct Java to use different predicate!

Hi Alex,

I undertood it now and it works for me.

It is actually a good example for me on overriding a function.

Thanks,

Robert
Hi Alex,

I undertood it now and it works for me.

It is actually a good example for me on overriding a function.

Thanks,

Robert