image-reflector-controller icon indicating copy to clipboard operation
image-reflector-controller copied to clipboard

refactor: make alphabetical sort implementation more intuitive

Open maybeanerd opened this issue 3 months ago • 0 comments

When looking into the implementation to understand behavior, it's very confusing to invert the ordering in relation to how the mental model works. This aligns implementation and mental model of the sort of versions in the end.

The part that was most confusing in my experience is that the docs vaguely mention "latest" and "last" element, but when looking at the implenetation, it seems we take the first element of the array - this is very unintuitive, and only makes sense after understanding that the implementation internally sorts exactly the other way around. This change should have no real impact on performance, but should make the code much more readable in my opinion. Tests are unchanged, because behavior is unchanged.

maybeanerd avatar Sep 25 '25 12:09 maybeanerd