Skip to content

Natural sort for package names - #6705

Open
JohnMcPMS wants to merge 3 commits into
microsoft:masterfrom
JohnMcPMS:natural-sort
Open

JohnMcPMS wants to merge 3 commits into
microsoft:masterfrom
JohnMcPMS:natural-sort

Conversation

@JohnMcPMS

@JohnMcPMS JohnMcPMS commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

📖 Description

Improve package-table sorting so versioned application names such as .NET Runtime 9.0 appear before .NET Runtime 10.0, without losing match relevance.

  • Add shared Utility::CompareNatural, using invariant, case-insensitive Windows numeric string comparison (CompareStringEx with LOCALE_NAME_INVARIANT, SORT_DIGITSASNUMBERS | SORT_STRINGSORT | LINGUISTIC_IGNORECASE).
  • Make relevance compare match type, then matched-field importance, instead of acting as a no-op. Default to {relevance, name}, preserving the existing name-only override for installed-package and upgrade lists without a query.
  • Apply presentation sorting to search results, installed-package/upgrade lists, and multiple-match candidate tables. Keep repository/API result ordering, result limits, eligibility, and upgrade execution order unchanged.
  • Add repeatable --sort and --ascending / --descending (including --asc / --desc) to search and upgrade, reusing the list command's argument definitions.

Windows collation defines display ordering; this does not normalize inconsistent publisher naming or define preview/release-channel precedence.

PS> winget search ".net runtime"
Name                                Id                               Version
------------------------------------------------------------------------------------------
Microsoft .NET Runtime 10.0         Microsoft.DotNet.Runtime.10      10.0.15
Microsoft .NET Runtime 8.0          Microsoft.DotNet.Runtime.8       8.0.34
Microsoft .NET Runtime 9.0          Microsoft.DotNet.Runtime.9       9.0.23
Microsoft .NET Runtime 11.0         Microsoft.DotNet.Runtime.11      11.0.0
Microsoft .NET Runtime 2.2          Microsoft.DotNet.Runtime.2_2     2.2.8.28209
Microsoft .NET Runtime 3.1          Microsoft.DotNet.Runtime.3_1     3.1.32
Microsoft .NET Runtime 5.0          Microsoft.DotNet.Runtime.5       5.0.17
Microsoft .NET Runtime 6.0          Microsoft.DotNet.Runtime.6       6.0.36
Microsoft .NET Runtime 7.0          Microsoft.DotNet.Runtime.7       7.0.20
Microsoft .NET Runtime 11.0 Preview Microsoft.DotNet.Runtime.Preview 11.0.0-rc.3.26522.148
PS> wingetdev search ".net runtime"
Name                                Id                               Version
------------------------------------------------------------------------------------------
Microsoft .NET Runtime 2.2          Microsoft.DotNet.Runtime.2_2     2.2.8.28209
Microsoft .NET Runtime 3.1          Microsoft.DotNet.Runtime.3_1     3.1.32
Microsoft .NET Runtime 5.0          Microsoft.DotNet.Runtime.5       5.0.17
Microsoft .NET Runtime 6.0          Microsoft.DotNet.Runtime.6       6.0.36
Microsoft .NET Runtime 7.0          Microsoft.DotNet.Runtime.7       7.0.20
Microsoft .NET Runtime 8.0          Microsoft.DotNet.Runtime.8       8.0.34
Microsoft .NET Runtime 9.0          Microsoft.DotNet.Runtime.9       9.0.23
Microsoft .NET Runtime 10.0         Microsoft.DotNet.Runtime.10      10.0.15
Microsoft .NET Runtime 11.0         Microsoft.DotNet.Runtime.11      11.0.0
Microsoft .NET Runtime 11.0 Preview Microsoft.DotNet.Runtime.Preview 11.0.0-rc.3.26522.148

🔍 Validation

Added or updated C++ tests cover the shared comparator, relevance buckets, stable ties, default/settings/argument precedence, command parsing and completion, presentation order, unchanged repository match vectors, and candidate-selection mapping.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS
JohnMcPMS requested a review from a team as a code owner November 23, 2026 19:03
@github-actions

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant