Skip to content

Instantly share code, notes, and snippets.

@fliedonion
Last active April 26, 2024 08:11
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fliedonion/6057f4a3a533f7992c60 to your computer and use it in GitHub Desktop.
Save fliedonion/6057f4a3a533f7992c60 to your computer and use it in GitHub Desktop.
Understand GIST file list order.
Summary How to control (or Understand) your GIST page's files list order.
Notice not official documentation.
This is sample file name leading number sign.
The reason of second charactor 'z' is :
bring this below the `#Control GIST File Order.md`
This is sample file name leading hyphen.
This is sample file name leading digits.

How to control GIST file listing order

PLEASE NOTE: This is NOT official specification document.

Basic Spec

  • Basically, ASCIIbetical order. But grouping by First character.
  • If two files have completely same name without casing, they will be ordered by creation time (older first).

First character

  • Some signs come before DIGITS
    • maybe !, #, - and . always come before digits 0-9.
  • Digits 0-9
  • Some signs come after DIGITS
    • maybe _ always come after digits 0-9.
  • Alphabetic characters come after signs and digits
    • ignore casing.

Extensions

Extensions are only characters part of filename.

Sample Cases

Case 1: same extensions

a_abc.txt, #_abc.txt, 1_abc.txt, __abc.txt will

Filenames
#_abc.txt
1_abc.txt
__abc.txt
a_abc.txt

Case 2: different extensions

a_abc.txt, #_abc.txt, 1_abc.txt, a_abc.md, #_abc.md, 1_abc.md, a_abc.js, #_abc.js, 1_abc.js, 2_abc.txt, 2_abc.md will:

Filenames
#_abc.js
#_abc.md
#_abc.txt
1_abc.js
1_abc.md
1_abc.txt
2_abc.md
2_abc.txt
a_abc.js
a_abc.md
a_abc.txt

Case 3: different names and same extension.

HIJ.txt, abc.txt, opQ.txt, HIK.txt will

Filenames
abc.txt
HIJ.txt
HIK.txt
opQ.txt

aaa.txt, ZZZ.txt will

Filenames
aaa.txt
ZZZ.txt

AAA.txt, zzz.txt will

Filenames
AAA.txt
zzz.txt

Thease means caracter-case are ignored.

Case 4: same name and extensions but different casing

a_abc.txt, a_ABC.txt

If you create a_abc.txt first, a_abc.txt comes before a_ABC.txt . If you create a_ABC.txt first, a_abc.txt comes after a_ABC.txt .

Conclusion

If you want to bring a file comes before any others, rename that file with leading ! is easy way.

This is sample file name leading underscore.
This is sample file name leading lower case character.
This is sample file name leading upper case character.
@nnzo
Copy link

nnzo commented Jun 3, 2020

This is really useful, thanks for this!
+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment