These sort of questions tend to attract lots of these sort of code examples. I don't know a whole lot about Java, but a lot of these answers don't even relate to the asked question as such, it's just some random snippet of sorting code. Shrug.
Personally, if I encounter these questions in a review queue I leave a comment in the form of:
Thanks for your answer, but it looks like someone else already answered this question several years ago: [..link to most similar answer..]
Half the time the poster will realize their mistake and self-remove the answer. Problem solved.
If they don't, shrug. I downvote if it's truly bad or misguided, but most of the times I don't. It's already at the bottom of the answer list and not likely to get any upvotes. I don't see how downvoting accomplishes anything other than potentially angering someone.
If I encounter it "by chance" – as you seem to have done – I typically don't do anything unless it's really bad or misguided, for the same reasons mentioned above.