Not sorted in alphabetical order #10202

Closed
opened 2025-12-29 21:28:15 +01:00 by adam · 2 comments
Owner

Originally created by @mikygee on GitHub (Sep 7, 2024).

Deployment Type

Self-hosted

NetBox Version

v4.1.0

Python Version

3.10

Steps to Reproduce

Create 2 platformes such as
FortiOS v7.0.9
FortiOS v7.0.15

Device > Device > Edit a device
Check the list platform in Device

Expected Behavior

FortiOS v7.0.15 should be inferior to v7.0.9

This is a typical problem because when comparing 15 and 9, the first caracter 1 is evaluated, and indeed 1 is inferior to 9.
But numbers should be evaluated together, 15 should be evaluated not 1 compared to 9 and then 5 compared to a space.

Observed Behavior

FortiOS v7.0.15 is superior to v7.0.9

image

Originally created by @mikygee on GitHub (Sep 7, 2024). ### Deployment Type Self-hosted ### NetBox Version v4.1.0 ### Python Version 3.10 ### Steps to Reproduce Create 2 platformes such as FortiOS v7.0.9 FortiOS v7.0.15 Device > Device > Edit a device Check the list platform in Device ### Expected Behavior FortiOS v7.0.15 should be inferior to v7.0.9 This is a typical problem because when comparing 15 and 9, the first caracter 1 is evaluated, and indeed 1 is inferior to 9. But numbers should be evaluated together, 15 should be evaluated not 1 compared to 9 and then 5 compared to a space. ### Observed Behavior FortiOS v7.0.15 is superior to v7.0.9 ![image](https://github.com/user-attachments/assets/75b2a9d6-4dc2-4154-befc-277ba70d4438)
adam closed this issue 2025-12-29 21:28:15 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 8, 2024):

This is alphabetical ordering: The string v7.0.15 comes before v7.0.9 because 1 comes before 9. What you're after is natural ordering. This is supported for certain models in NetBox currently but not for platforms. Please see #11279 for further discussion.

@jeremystretch commented on GitHub (Sep 8, 2024): This _is_ alphabetical ordering: The string `v7.0.15` comes before `v7.0.9` because 1 comes before 9. What you're after is [natural ordering](https://en.wikipedia.org/wiki/Natural_sort_order). This is supported for certain models in NetBox currently but not for platforms. Please see #11279 for further discussion.
Author
Owner

@mikygee commented on GitHub (Sep 8, 2024):

Thank you Jeremy for your answer.

@mikygee commented on GitHub (Sep 8, 2024): Thank you Jeremy for your answer.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10202