Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Index::LabelCompare do numeric comparison on the subscript (numeric) part of an index. #172

Open
bimalgaudel opened this issue Jan 2, 2024 · 1 comment

Comments

@bimalgaudel
Copy link
Member

bimalgaudel commented Jan 2, 2024

As of now:
Index{L"i_10"} < Index{L"i_2"} is true.

After:
Index{L"i_10"} > Index{L"i_2"} is true.

While equality (==) (or !=) holds with either string comparison or numeric comparison, ordering/sorting is likely to introduce a bug with string comparison alone, as the programmer naturally might expect a numeric comparison on the numeric portion.

@Krzmbrzl
Copy link
Collaborator

Krzmbrzl commented Feb 6, 2024

The symptoms have been fixed in #177 but imo indices should be refactored to contain a label (string) and an ID (integer) as two separate members. Then comparing the ID numerically is easy.
Where needed the two components could be merged into a single string very easily (easier than it is to disassemble the string into the two components)

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

No branches or pull requests

2 participants