How do you control the order in which files appear

2019-01-31 02:30发布

问题:

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?

回答1:

It seems to be a simple ASCIIbetical order (in 2013-2014).

ASCII-code order is also called ASCIIbetical order.
Collation of data is sometimes done in this order rather than "standard" alphabetical order (collating sequence). The main deviations in ASCII order are:

  • All uppercase come before lowercase letters, for example, "Z" before "a"
  • Digits and many punctuation marks come before letters, for example, "4" precedes "one"
  • Numbers are sorted naïvely as strings, for example, "10" precedes "2"

Since you have a file starting with 'G', it will precedes a "README.md".


Since then, in 2018, the order seems more alphabetical.
See also github issue 195.

it'd be nice for README.md to appear on top, without having to call it 00-README or such...



回答2:

They are ordered automatically by name, following the ASCII table.

Unfortunatly, right now, it is not possible to order them by dragging, but there is a trick. You can control the order by adding one or more spaces before the name. The space will not be shown after editing, but the order will change.

E.g: lets say we have 3 files with the automatic order:

  • AFile.java
  • Readme.md
  • SomeFile.txt

We can invert the order by putting spaces like this:

  • (space)(space)SomeFile.txt
  • (space)Readme.md
  • AFile.txt


回答3:

As mentioned by @VonC in his answer, the order is asciibetical. Quick solution would be to prefix all files with numbers indicating the order in which you wish the files to appear, example 0_, 1_, 2_, ... 9_. Note, this solution will not work beyond 9 files as 10_ will appear before 2_. In that case, two digits need to be used 00_, 01_, 02_, ..., 09_, 10_, 11_, ... This can be generalized to any number of digits in the number of files. Although, it seems less likely, to me, that more more than 10 files to be shared in a gist.



标签: github gist