Svullo Svullosson

Greenhorn
+ Follow
since May 19, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Svullo Svullosson

True, my memory failed me since I typically never edit. The reason I did this time is it was motivated, inconsequential and documented:He asked me to put it into his code, at which point I realized the mismatch between his question and code and adapted mine and noted why. So I really don't see the problem. But that's me and I wont disturb you further.
1 year ago

Campbell Ritchie wrote:Kindly don't edit posts like that after they have been replied to; I have undone the edit.


Who says I edited it after anyone replied to it?
1 year ago

Piet Souris wrote:This is not quite according to the specs that OP mentioned in his opening post.



I started out replying with the same code you just posted, then I realized that he had, in his code, mapped employees to names so I assumed that was his actual intention and changed my reply. Hence the "edit:" note on my post.
1 year ago
Sorry, I was a bit sloppy writing that initial reply, it should be
1 year ago
The .collect(TreeSet::new) is to replace the .collect(...) you've already got at line 12 of your code.

If you instead stick with your current list and use Collections.sort(...),  that would go right after the .collect(...) but before printing, i.e. at line 13.

As has been suggested. you could also look into Stream.sorted(). For performance in a real life setting I would assume that collecting into a TreeSet would be best, followed by Collections.sort(...) and then Stream.sorted(), but that's just a guess.
1 year ago
Maybe collect into a sorted collection:


But that's a set. If you need it to be a list you could just add

1 year ago