-
Notifications
You must be signed in to change notification settings - Fork 53
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
Pattern viewer configuration and styling #1336
base: dev
Are you sure you want to change the base?
Conversation
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.
We can make this much smaller!
) | ||
|
||
const headsigns = sortPatternsByVehicleCount | ||
? unsortedHeadsigns.sort((a, b) => { | ||
// sort by number of vehicles on that pattern |
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.
We can avoid adding the new variable and the ternary if you instead add an if(!sortPatternsByVehicleCount) return 0
at the top of the original sort method
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.
Isn't it more efficient to avoid iterating through the sort
if we don't have to?
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.
If we always return 0 it's still O(n) and the code is much cleaner
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.
Wonderful!
Description:
sortRoutePatternsByVehicles
which makes sorting the route patterns by vehicle count in the dropdown optional.PR Checklist:
|