How do you control the order in which files appear in a GitHub gist

Sinetheta picture Sinetheta · Jul 16, 2013 · Viewed 15.3k times · Source

Is there a way to control the order in which files appear in a gist? They don't seem to be alphabetical or chronological. I'd like to have a README.md appear as the first file in a multi-file gist, but no amount of "deleting" a file and re-adding it seems to change anything.

Is there an order to these files that I'm not seeing, or does GitHub maintain an internal filetype priority list?

Answer

VonC picture VonC · Jul 16, 2013

Since at least 2018, the order is alphabetical, with periods and numbers coming before letters.

That is, as mentioned in Andrew D.Bond's answer:

  1. $
  2. . (dot)
  3. Numbers
  4. Leading space (although the space doesn't appear after saving, the sort order is still updated)
    (although bis, in Sept. 2020, IvanaGyro adds in the comments leading spaces will not affect the order any more)
  5. _ (underscore)
  6. Letters (case insensitive)

Around 2013-2014 a different order was used.