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

Order of annotation sets in tag detail pages #125

Merged
merged 3 commits into from
Dec 26, 2024
Merged

Conversation

ajolipa
Copy link
Contributor

@ajolipa ajolipa commented Dec 23, 2024

In this PR

Quick and dirty fix for the fact that annotations sets are being displayed in an apparently nonsensical order on the various tag detail pages. This fix should have them ordered alphabetically by event label and then alphabetically by set name.

Copy link
Contributor

@lwjameson lwjameson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Contributor

@camdendotlol camdendotlol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor change request. Feel free to merge when it's done since I won't be around to approve.

const event_a = events.find((ev: any) => ev.id == a.data.event_id);
const event_b = events.find((ev: any) => ev.id == b.data.event_id);
if (event_a && event_b) {
return event_a.data.label < event_b.data.label
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing strings with < and > is case-sensitive:

const letters = ['A', 'a', 'B', 'z', 'Z']

console.log(letters.sort())
// ["A", "B", "Z", "a", "z"]

console.log('a' > 'b') // false
console.log('a' > 'B') // true

Converting the labels to lowercase before comparing would prevent unexpected sorting behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, good call.

@ajolipa ajolipa merged commit d788d97 into develop Dec 26, 2024
@ajolipa ajolipa deleted the RB-tag-ordering branch December 26, 2024 21:39
@ajolipa ajolipa linked an issue Jan 2, 2025 that may be closed by this pull request
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.

Index page ordering seems random
3 participants