DEV Community

Cover image for When you so done with Stackoverflow sorting accepted answers wrong
Jay Wick
Jay Wick

Posted on

When you so done with Stackoverflow sorting accepted answers wrong

Hold my beer, imma write a web extension

I'm aware some already exist, but nothing that respects the super odd anchoring system they have.

Scratch code so far is

[...document.querySelectorAll('#answers > div.answer')].reduce((acc, el) => [...acc, {anchor: el.previousElementSibling, answer: el, votes: +el.querySelector('div[itemprop="upvoteCount"]').getAttribute('data-value')}], []).sort((a, b) => b.votes - a.votes)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)