Show the Top Five Comment Scores on a SE Post A Stack Exchange script determines which five comments on questions or answers are initially seen on the main page of sites through the number of upvotes on them; the five comments with the highest number of votes are displayed. Your task is to recreate this behavior.

Write a full program or function taking input through STDIN, command-line args, or function arguments and prints or returns the top five comment scores. Input will be an array of integers representing the number of upvotes on the comments of some post. For instance, an input of

0, 2, 5, 4, 0, 1, 0


means that the first comment has no votes, the second one has two votes, the third has five, the fourth had four, etc. The order of the comment scores should remain the same in the output.

If the input contains five or fewer comment scores, then the output should contain nothing more than the ones given. If two or more comment scores are the same, the first score(s) should be displayed. You may assume that the input array will contain at least one comment score.

The numbers in the output should be easily distinguished (so 02541 for case 1 is invalid). Otherwise there are no restrictions on output format; the numbers may be separated by a space or newline, or they may be in list format, etc.

Test cases:

[0, 2, 5, 4, 0, 1, 0] -&gt; [0, 2, 5, 4, 1]
[2, 1, 1, 5, 3, 6] -&gt; [2, 1, 5, 3, 6]
[0, 4, 5] -&gt; [0, 4, 5]
[1, 1, 5, 1, 1, 5] -&gt; [1, 1, 5, 1, 5]
[0, 2, 0, 0, 0, 0, 0, 0] -&gt; [0, 2, 0, 0, 0]
[0, 0, 0, 0, 1, 0, 0, 0, 0] -&gt; [0, 0, 0, 0, 1]
[5, 4, 2, 1, 0, 8, 7, 4, 6, 1, 0, 7] -&gt; [5, 8, 7, 6, 7]
[6, 3, 2, 0, 69, 22, 0, 37, 0, 2, 1, 0, 0, 0, 5, 0, 1, 2, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2] -&gt; [6, 69, 22, 37, 5]


The last example was taken from this Stack Overflow question.

If possible, please provide a link in your post where your submission can be run online.

This is code golf, so the shortest code in bytes wins. Good luck!
Jelly, 6 bytes

NỤḣ5Ṣị


Try it online! or verify all test cases at once.

How it works

NỤḣ5Ṣị    Main link. Input: A (list)

N         Negate (multiply by -1) all elements of A.
 Ụ        Grade the result up.
          This consists in sorting the indices of A by their negated values.
          The first n indices will correspond to the n highest vote counts,
          tie-broken by order of appearance.
  ḣ5      Discard all but the first five items.
    Ṣ     Sort those indices.
          This is to preserve the comments' natural order.
     ị    Retrieve the elements of A at those indices.