So I have a List<String> L1 = new ArrayList<>()
with the following strings as elements:
- l, l, u, u.
- r, u, d, l, d, l, u.
- l, u, d, r, r, r, r, r, u, d.
- l, u.
- l, u, r.
How do I sort the list
by its element's size so that in the final state L1 should be like this:
- l, u.
- l, u, r.
- l, l, u, u.
- r, u, d, l, d, l, u.
- l, u, d, r, r, r, r, r, u, d.
I have tried using Collections.sort
, but that sorts alphabetically, which is obviously not what I want.