Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Drive names were sorted lexicographically, causing pd10 and pd11 to appear before pd2-pd9.

Changes

  • Added string_natural_compare() in src/hz/string_algo.h: Compares strings with numeric sequences treated as numbers rather than character-by-character
  • Updated StorageDevicePtr comparison operator in src/applib/storage_device.h: Replaced string comparisons with natural sort for device base names, virtual filenames, and type arguments
  • Added test coverage in src/hz/tests/test_string_algo.cpp: 29 assertions covering device name sorting and edge cases

Example

Before:

pd0, pd1, pd10, pd11, pd2, pd3, pd4, pd5, pd6, pd7, pd8, pd9

After:

pd0, pd1, pd2, pd3, pd4, pd5, pd6, pd7, pd8, pd9, pd10, pd11

Algorithm compares numeric sequences by magnitude:

string_natural_compare("pd2", "pd10")   // returns < 0 (2 < 10)
string_natural_compare("pd9", "pd10")   // returns < 0 (9 < 10)
string_natural_compare("pd10", "pd11")  // returns < 0 (10 < 11)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Natural sort order</issue_title>
<issue_description>Version and Environment

  • GSmartControl version: 2.0.2
  • OS: Windows 11 24H2

Is your feature request related to a problem? Please describe.
N/A

Describe the solution you'd like
Please use natural sort order, rather than machine-oriented, pure alphabetical sort order.

Describe alternatives you've considered
N/A

Additional context

In the screenshot below, pd10 and pd11 should come after pd9.

Image
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add natural sort order for display items Implement natural sort order for drive names Nov 18, 2025
Copilot AI requested a review from ashaduri November 18, 2025 19:19
Copilot finished work on behalf of ashaduri November 18, 2025 19:19
@ashaduri ashaduri closed this Nov 25, 2025
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.

Natural sort order

2 participants