Screenshot of Code Golf SE answer sorter user script


This script adds a "shortest" tab to pages on the Programming Puzzles & Code Golf Stack Exchange site. Clicking the tab will sort answers in decreasing order by the length of the first code block in the answer. It was written as a simple replacement for the original codegolf.SE user script that broke with the new Stack Exchange top bar.

The new tab functions pretty much like the normal "active", "oldest" and "votes" tabs, except for a couple of small quirks:

  • The information about whether or not the new tab is selected is stored in your browser. It is thus not synchronized across multiple browsers or computers.

  • If there are so many answers (over 30, currently) that they get split over multiple pages, the script will only re-sort the answers on the currently visible page; it will not pull answers from other pages, even if they might have a lower golf score.

  • Related to the above, since the choice of which answers are visible on the page may depend on the actual server-side sorting order active before the script runs, this is indicated by a small dashed yellow line under the corresponding tab. To change the server-side sorting mode, click one of the other tabs and then click "shortest" again.

  • Deleted answers and answers with a voting score of -3 or less are always sorted to the end of the page. (Technically, the sorting code ignores them entirely.) Answers that include a code block, however long, are always sorted before answers that don't. Answers with equal golf score are sorted randomly. The accepted answer is currently not always sorted first.


This script is released into the public domain per the Creative Commons CC0 public domain dedication. Feel free to do whatever you want with it.

Download / Install

This user script is hosted on GitHub. If you have a suitable user script management extension (such as GreaseMonkey for Firefox or Tampermonkey for Chrome) installed, clicking the "download / install" button below should bring up a dialog asking you if you want to install this user script:

Download / Install

view source

For more information on how to install user scripts, see the script tag wiki.


This user script has been tested on Mozilla Firefox and Google Chrome. It should work on any browser with a compatible user script API, including Opera and Safari. Please report any incompatibilities you may find.


  • 4
    One of these days, I will update that UserScript. But it's great to hear that users have a suitable replacement in the mean time. Commented Jun 8, 2014 at 19:59


You must log in to answer this question.

Browse other questions tagged .