What is the default order for the result set from the Get-ChildItem command in powershell?

What is the default order for the result set from the Get-ChildItem command in powershell? Is there an order at all or is it just random and each time gives the results in a different order.

+4
source share
3 answers
First folders in alphanumeric order (first numbers as [char]). Then files in alphanumeric order (first numbers as [char]). 
+1
source

There is no guaranteed default sort order. The documentation is not indicated.

The implementation in FileSystemProvider ends with a call to DirectoryInfo.GetFiles . The documentation for this condition

The order of the returned file names is not guaranteed; use the sort method if a specific sort order is required.

The calls to the FindFirstFile and FindNextFile APIs are listed below. Raymond Chen explains here that in practice, the file system driver may observe some ordering rules, but should not be relied on.

+4
source

The default sort does not work for me. I get:

 Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 2015-10-12 10:51 tools d---- 2015-10-12 10:58 cfg d---- 2015-10-12 10:51 res d---- 2015-10-12 10:50 brand d---- 2015-10-12 10:51 lib 

I don’t remember changing the sort order. I am on Windows 7 SP1. If I need a sorted result, I need to do ls | sort ls | sort .

+2
source

All Articles