Sort will accept a redirected or piped file input and TYPE the file, sorted line by line.
Syntax SORT [options] Options /+n Sort the file ignoring the first one or more characters in each row. The default (/+1) will sort using all characters in each row. /+2 will start comparing at the second character, /+3 the third etc. Lines with fewer than n characters collate before other lines. /C[ASE_SENSITIVE] Case sensitive sort. (undocumented switch in Win7 and above) [drive:][pathname] The file to be sorted. If not specified, the standard input is sorted. Specifying an input file is faster than redirecting the same file as standard input. /L[OCALE] locale Override the system default locale with the specified one. The "C" locale yields the fastest collating sequence and is. currently the only alternative. The sort is always case insensitive. /M[EMORY] kilobytes The amount of main menory to use for the sort, in KiB. The best performance is usually achieved by not specifying a memory size. The memory size is always constrained to be a minimum of 160 KiB. If the memory size is specified the exact amount will be used for the sort, regardless of how much main memory is available. By default the sort will be done with one pass (no temporary file) if it fits in the default maximum memory size, otherwise the sort will be done in two passes (with the partially sorted data being stored in a temporary file) such that the amount of memory used for both the sort and merge passes are equal. The default maximum memory size is 90% of available main memory if both the input and output are files, and 45% of main memory otherwise. SORT will only create a temporary file when required by limitations in available memory. /REC[ORD_MAXIMUM] characters The maximum number of characters in a row or record (default 4096, maximum 65535) /R[EVERSE] Reverse the sort order (Z to A, 9 to 0) /T[EMPORARY] [drive:][path] The path of the directory to hold SORT's working storage, in case the data does not fit in RAM. The default is the system temporary directory %temp% /O[UTPUT] [drive:][pathname] The file where the sorted input is to be stored. If not specified, the data is written to standard output. Specifying an output file is faster than redirecting standard output to the same file. /U[NI_OUTPUT] Output in unicode. (undocumented switch in Win7 and above) /UNIQ[UE] Output only unique lines (undocumented switch in Windows 10 and above)
Because the /C and /U options are undocumented it is possible that they contain unfixed bugs e.g. some Unicode characters may not sort correctly.
Sort the file C:\demo\musiclist.txt
Pipe the output of a DIR command into SORT
DIR /b "C:\demo\" | SORT
Pipe the output from DIR into SORT, reverse the list and save into a file
DIR /b | SORT /r /o demo.txt
Pipe the output from DIR into SORT, and include any errors in the output (by redirecting the error stream):
DIR /b "folder-that-doesnt-exist" 2>&1 | SORT /r /o demo.txt
"Cultivate peace and order before confusion and disorder" ~ Tao Teh Ching
TYPE - Display the contents of a text file.
Redirection - Redirect files, command output and error messages.
Powershell: Sort-Object - Sort objects by property value (sort).
Equivalent bash command (Linux): sort - Sort text files.