-
Notifications
You must be signed in to change notification settings - Fork 887
feat: sort users by username #7838
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
Conversation
return a.ID.String() < b.ID.String() | ||
} | ||
return a.CreatedAt.Before(b.CreatedAt) | ||
return sort.StringsAreSorted([]string{a.Username, b.Username}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This is essentially just a a.Username < b.Username
comparison, could be simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
coderd/users_test.go
Outdated
return users[i].ID.String() < users[j].ID.String() | ||
} | ||
return users[i].CreatedAt.Before(users[j].CreatedAt) | ||
return sort.StringsAreSorted([]string{users[i].Username, users[j].Username}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, users[i].Username < users[j].Username
or sort.Strings
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
This PR modifies the default behavior of the
/users
API to return users sorted by username. Currently, they are sorted by creation date (not sure why?).Currently (not sorted):