简体   繁体   中英

What is the "no sorting" order when referring to the GLOB_NOSORT flag

Every file-system directory menu/tree I have ever laid eyes on has always ordered files az with special characters either before or after (assumably in ASCII code order). I was looking at the GLOB_NOSORT flag and it is described as ...

GLOB_NOSORT - Return files as they appear in the directory (no sorting). When this flag is not used, the pathnames are sorted alphabetically

To me, files "appear in the directory" alphabetically anyway, so what is the no sorting order?

Is it ascii code order, filectime ? filemtime or neither and does this differ depending on whether you are using window or linux

Also if its not obvious from your answer, how does this differ from "alphabetically".

Filesystems don't necessarily order files in any particular order. Even though the visual representation is sorted, since that's what users want, the actual contents on disk are not that.

So when using this flag you are given whatever happens to be on the disk without sorting.

Think what would happen if on every file delete/creation/move/rename the filesystem would take all the filenames in the directory, sort them based on possibly desired representation and then rewrite them. It would slow things down immensely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM