I have a directory of files that I needed to sort (case-sensitive). I invoked the command, but it is not giving the correct output. I tried ("BjFuHnTV.txt","bALAahas.txt") | Sort -CaseSensitive
as a test, and it is outputting bALAahas.txt BjFuHnTV.txt
, which is clearly false. The correct output should be BjFuHnTV.txt bALAahas.txt
. Using the -Descending
flag would not solve my problem either because I am trying to sort the strings in lexicogrophically ascending order.
Sorting the same two strings in Python gives the opposite result, and I am not sure why PowerShell is sorting these two strings incorrectly, even with the appropriate flags.
I am using PowerShell 7.0.6 (LTS) on Windows 10.
EDIT:
B
has a lower ordinal value than b
in ASCII (66 vs 98 respectively), so it should obviously come first in the sorting. Bash was sorting this correctly, but PowerShell is not working as expected.