24

When we access a question on Stack Overflow, the answers for the question are arranged in such a way that the accepted answer comes first. Then after the various answers are mixed up in the descending order of post time.

Can we think of ordering them according to the votes they got so that users who are in search of the best solutions get the answers without being mixed up with those with low quality?

4
  • 5
    The default sort order is by votes. The system remembers the last tab you selected and makes that your default. Accepted answers not by the original poster will always appear first. The rest ordered by whichever tab you select. I suggest you reword or rephrase your request, because in it's current state it really makes absolutely no sense. Commented Mar 28, 2012 at 11:30
  • 4
    you have to click only once. System remembers your last setting ed: Dang, ninja'd by @Diago the destroyer :P (ps: Hi Diago!) Commented Mar 28, 2012 at 11:30
  • 4
    @Diago: Thanks.. I dint realise system remembers the last tab you selected function.. ur comment made it clear for me. Commented Mar 29, 2012 at 10:05
  • 4
    +1: Haha, more than one year ago I thought, darn, why did they change the order. Only now I realize that I actually changed it myself. Commented Apr 16, 2013 at 7:50

3 Answers 3

39

I think you missed the tabs at the top of the answer section -

enter image description here

You can order them by votes.... The accepted answer will appear at the top because...well... its the accepted answer :P

Ordering by votes will then place the highest community voted answer right beneath the accepted one.

7
  • 5
    The accepted answer appears first only when it was not written by the user who asked the question; differently, the accepted answer is sorted as if it was not accepted.
    – avpaderno
    Commented Mar 28, 2012 at 11:24
  • Yes there is option for odering them by cking on the tabs, but why can it be the initial display option? Commented Mar 28, 2012 at 11:25
  • The initial display option will be your last selection.
    – Lix
    Commented Mar 28, 2012 at 11:25
  • @mithunsatheesh: The initial selection is by votes... Commented Mar 28, 2012 at 11:56
  • @Bobby: i think what Diago commented below the question is right. Commented Mar 29, 2012 at 10:01
  • 1
    @Bobby: it says The system remembers the last tab you selected and makes that your default. . Commented Mar 29, 2012 at 10:02
  • @mithunsatheesh: And if you've never selected one, it's by votes. Commented Mar 29, 2012 at 10:14
2

There is only one accepted answer, and that's what it is for - there's one pinned answer when ordering by "votes".

I see nothing wrong with it.

3
  • but there can be chance that a better answer was proposed after the user accepting the answer. And the user who asked the question dint accept the new one. And the new answer gets more votes than the accepted.? Commented Mar 28, 2012 at 11:19
  • 5
    The OP gets to choose the accepted answer - the community will choose the best one.
    – Lix
    Commented Mar 28, 2012 at 11:22
  • @Lix that's possible, but remember that there's only ONE answer which is accepted. I think that it means it should be always at top
    – Martin.
    Commented Mar 28, 2012 at 11:46
1

To sort by vote including the accepted answer:

  1. On FireFox, add the Chee's Javascript extension
  2. On Chrome, add the Control Freak extension
  3. Go on Stackoverflow
  4. Click on the icon of the extension
  5. Select edition on domain
  6. Paste the following Javascript:

    if (window.location.href.includes('stackoverflow.com/questions')) {
        var answers = document.getElementById('answers');
        var elements = answers.getElementsByClassName('js-vote-count');
        var acceptedElement = null;
    
        for (var i = 0; i < elements.length; i++) {
            var parent = elements[i].parentElement;
            if (parent.getElementsByClassName('d-none').length == 0) {
                acceptedElement = elements[i]
            }
        }
    
        if (acceptedElement != null) {
            var acceptedElementVote = parseInt(acceptedElement.innerText, 10);
            var betterVotedElement = null;
    
            for (var i = 0; i < elements.length; i++) {
                var currentElementVote = parseInt(elements[i].innerText, 10);
    
                if (acceptedElementVote < currentElementVote
                        && (betterVotedElement == null
                                || currentElementVote < parseInt(betterVotedElement.innerText, 10)
                                || (currentElementVote == parseInt(betterVotedElement.innerText, 10)
                                        && elements[i].compareDocumentPosition(betterVotedElement) == 2))) {
                    betterVotedElement = elements[i]
                }
            }
    
            if (betterVotedElement != null) {
                var acceptedAnswer = acceptedElement.parentElement.parentElement.parentElement.parentElement;
                var betterVotedAnswer = betterVotedElement.parentElement.parentElement.parentElement.parentElement;
                acceptedAnswer.parentNode.removeChild(acceptedAnswer);
    
                if (betterVotedAnswer.nextSibling != null) {
                    betterVotedAnswer.parentNode.insertBefore(acceptedAnswer, betterVotedAnswer.nextSibling);
                } else {
                    betterVotedAnswer.parentNode.appendChild(acceptedAnswer);
                }
            }
        }
    }
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .