-
Notifications
You must be signed in to change notification settings - Fork 255
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
Docs: Missing reference for sort #545
Comments
I've seen sort used in commits to @browser in order to control the order of divs, and I've had no problem using other functions and expressions in commit and bind, as long as they are not affecting the query. This works for selecting the last element after sorting on a field. search search Regards, |
I'm going to close this and reopen it in the docs repo. You can track it here: #545 I'll answer your question now and sort of use that as an interim sort doc until I can get something more substantial together. Syntax
Arguments
The output of the function is a set of indices, each of which map to an element of the sorted attribute. For example, if the value is (" ExamplesWe have #student records with grade (1 - 12), teacher, GPA (0.0 - 4.0) attributes. We can sort the students by grade:
The browser handles the task of rendering the divs in the order specified by the
You can also sort across multiple axes of a record. For instance, we can sort grade from 9 to 12, then sort by name from Z - A.
This can be extended to sort any number of attributes
Finally, we can group sorted attributes with the per argument. Here you can see the difference between sorting by name then grade, and sorting by name per grade.
When you sort per grade, then name is first grouped by grade, and each of those groups is then sorted. This is why index goes from 1-6 instead of 1-20 as in the other examples; Although there are still 20 elements in index, the maximum is 6 because no grade has more than 6 students. You might want to sort data this way in order to display it in a nested structure, such as this:
Commit some test data
|
Okay it's in: witheve/docs#27 Please let me know if this makes sense. Sort is simple in the base case, but can get complicated. |
It is used a couple of places in the examples (like
view.eve
), but nothing that explains what it is and how it can be used...For instance, I'm interested in limiting a search to only match the last record. Can/should I use sort for this, and if so, how?
Can sort be used in other places than
search
?The text was updated successfully, but these errors were encountered: