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

0014-loan-comparison assumes that sorting keeps the original order #651

Open
SimonRinguette opened this issue Mar 21, 2024 · 2 comments
Open

Comments

@SimonRinguette
Copy link
Contributor

In the 0014-loan-comparaison test case, it uses the sort function to sort based on the rate.

Multiple products have the same rate (0.01325 and 0.03250).

The test case assumes that the sort algorithm used by the implementation keep the original order for items when they are equal.

HOWEVER, the sort function second parameter (the precedes function) is a boolean function that return true or false depending if the element precedes but there is no information about equality of objects.

Therefore, some sorting algorithms would not guarantee the order of the elements and this test case is biased toward a sorting that keep the order of the elements and from the spec, it does not mention that this is a requirement.

I would suggest modifying the rates of the products to make sure it fits all sorting algorithms (no duplicate rates).

@baldimir
Copy link
Collaborator

Based on the discussion on the meeting: There is a gap in the spec. When considering equality of the sorting function, there is no guarantee with more complex sorting algorithms, that the order of equal items based on the sorting function will stay the same.

Example:
Complex object:
attribute1 = 10
attribute2 = 15
Complex object:
attribute1 = 10
attribute2 = 20

Sorting by attribute1 can lead to first object ending first in some sorting algorithms and second object in the other.

@SimonRinguette
Copy link
Contributor Author

Raised an RTF issue: https://issues.omg.org/issues/INBOX-1873

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

No branches or pull requests

2 participants