PowerShell / PowerShell/vscode-powershell
Command Explorer doesn't sort like Show-Command
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 547
- PR merge metrics
- No merged PRs in 30d
Description
The original intent behind Command Explorer was to mimic Show-Command. I noticed today that Show-Command sorts with the hyphens being of higher sort value than other letters. While the Sort-Object that we use in the Command Explorer seems to strip out the hyphens and sorts based on the result. So you'll see some Convert-Toxxx and then ConvertTo-yyy followed by Convert-Tozzz.
System Details
This happens with Windows PowerShell 5.1 on Windows 10 1709 and insiders build 18898 as well as PowerShell Core 6.2. As such, I'm going to forego the vscode version and PSES.
Issue Description
Example of 4 made up functions:
PS> function ConvertTo-Lkj {}
PS> function Convert-ToLkj {}
PS> function Convert-Lkj {}
PS> function ConvertLkj {}
When running Show-Command and then sorting for lkj:

When running the equivalent Get-Command code Get-Command *lkj | select name | Sort name | ogv:

I have also tested this in pwsh with the same behavior:
PS> function ConvertTo-Lkj {}
PS> function Convert-ToLkj {}
PS> function Convert-Lkj {}
PS> function ConvertLkj {}
PS> get-command *lkj | select name | sort name
Name
----
ConvertLkj
Convert-Lkj
ConvertTo-Lkj
Convert-ToLkj
Expected Behaviour
Output commands in the order:
Convert-Lkj
Convert-ToLkj
ConvertLkj
ConvertTo-Lkj
Actual Behaviour
Output commands in order:
ConvertLkj
Convert-Lkj
ConvertTo-Lkj
Convert-ToLkj
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Command Explorer sorting path and locating the Sort-Object behavior described in the issue. Reproduce the four sample command names, compare the result with Show-Command, and consider the work done when Command Explorer orders them as shown under Expected Behaviour.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100