-
Notifications
You must be signed in to change notification settings - Fork 9k
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
sort routes alphabetically (254) #496
Conversation
new option sortAlphabetical=true|false
actually this belongs on #254 |
hi @rage-shadowman you mean pass the sorter into the MainView? and instead of sortAlphabetically=true you have something like sort=alpha where alpha maps to the function? |
I mean rather than setting options.sortAlphabetically to a boolean, you would set options.sorter or maybe options.sortFn to a function, which, in your example would be the alphabetical sorter function. We could make it sort any way we like by just passing in a different function which might take into account whether it is a GET or POST, or the number of required arguments or anything else we might want to use. |
changed option name to 'sorter' and documented in README.md. |
sort routes alphabetically (254)
Ok, I think I see what 'method' is for. Not as hideous as I thought, but still more complicated than it needs to be and crippled in functuonality. |
okay now i understand your original meaning of passing the sorter through ... sorry, i didn't fully get it before. i think there are some advantages to providing these predefined sorters:
but ideally both predefined sorters AND a custom / pass through sorter is supported. maybe we can do something like : if 'sorter' type is 'string' then it's a reference to a predefined sort otherwise it's a provided function... |
A sorter always needs to know the structure of what it is sorting, that is just the nature of the beast. So it would probably make sense to have 2 separate sorters for this: apiSorter and operationSorter. You can see my fork for an example if you like. I haven't tested it so I didn't send a pull request. And maybe it should allow strings but check if the parameter is of type 'function'. It may even be useful to have a propertySorter for models. |
sort routes alphabetically (254)
No description provided.